Warning: Use of undefined constant Symbol - assumed 'Symbol' (this will throw an Error in a future version of PHP) in /mnt/new-ebs/workbench-106550/lib/dojo/util/docscripts/lib/parser2/dojo2.inc on line 215 Warning: Use of undefined constant JavaScriptSymbol - assumed 'JavaScriptSymbol' (this will throw an Error in a future version of PHP) in /mnt/new-ebs/workbench-106550/lib/dojo/util/docscripts/lib/parser2/dojo2.inc on line 215

dojox/math/round.js

  • Provides:

    • dojox.math.round
  • dojox.math.round

    • parameters:
      • value: (typeof Number)
        The number to round
      • places: (typeof Number)
        The number of decimal places where rounding takes place.  Defaults to 0 for whole rounding.
        Must be non-negative.
      • increment: (typeof Number)
        Rounds next place to nearest value of increment/10.  10 by default.
      • v
      • p
      • m
    • returns
      Number
    • summary
      Similar to dojo.number.round, but compensates for binary floating point artifacts
    • description
      Rounds to the nearest value with the given number of decimal places, away from zero if equal,
      similar to Number.toFixed().  Rounding can be done by fractional increments also.
      Makes minor adjustments to accommodate for precision errors due to binary floating point representation
      of Javascript Numbers.  See http://speleotrove.com/decimal/decifaq.html for more information.
      Because of this adjustment, the rounding may not be mathematically correct for full precision
      floating point values.  The calculations assume 14 significant figures, so the accuracy will
      be limited to a certain number of decimal places preserved will vary with the magnitude of
      the input.  This is not a substitute for decimal arithmetic.
    • example
      >>> 4.8-(1.1+2.2)
      1.4999999999999996
      >>> Math.round(4.8-(1.1+2.2))
      1
      >>> dojox.math.round(4.8-(1.1+2.2))
      2
      >>> ((4.8-(1.1+2.2))/100)
      0.014999999999999996
      >>> ((4.8-(1.1+2.2))/100).toFixed(2)
      "0.01"
      >>> dojox.math.round((4.8-(1.1+2.2))/100,2)
      0.02
      >>> dojox.math.round(10.71, 0, 2.5)
      10.75
      >>> dojo.number.round(162.295, 2)
      162.29
      >>> dojox.math.round(162.295, 2)
      162.3
    • alias - dojox.math.round
    • type
      Function
  • dojox.math

    • type
      Object
  • dojox

    • type
      Object