Skip to content

Commit

Permalink
FLUID-6125: Updated docs for changed rounding rules
Browse files Browse the repository at this point in the history
  • Loading branch information
jobara committed Feb 13, 2017
1 parent 0347a11 commit b4afc51
Show file tree
Hide file tree
Showing 2 changed files with 2 additions and 2 deletions.
2 changes: 1 addition & 1 deletion src/documents/CoreAPI.md
Expand Up @@ -259,7 +259,7 @@ var max = Math.max.apply(null, numbers);
* `num {Number}` The number to be rounded
* `scale {Number}` The maximum number of decimal places to round to. If the scale is invalid (i.e falsey, not a number, negative value), it is treated as 0. If the scale is a floating point number, it is rounded to an integer.

Derived from [AGK's stack overflow](http://stackoverflow.com/a/12830454) answer, it rounds the supplied number to at most the number of decimal places indicated by the scale, omiting any trailing 0s. Similar to [`Math.round`](https://www.ecma-international.org/ecma-262/5.1/#sec-15.8.2.15), numbers are rounded towards +∞ (i.e 0.5 -> 1, -0.5 -> 0).
Derived from [AGK's stack overflow](http://stackoverflow.com/a/12830454) answer, it rounds the supplied number to at most the number of decimal places indicated by the scale, omiting any trailing 0s. Similar to [`Math.round`](https://www.ecma-international.org/ecma-262/5.1/#sec-15.8.2.15), numbers are rounded away from 0 (i.e 0.5 -> 1, -0.5 -> -1).

```javascript
var rounded = fluid.roundToDecimal(1.555, 2) // rounded now holds 1.56
Expand Down
2 changes: 1 addition & 1 deletion src/documents/ModelTransformationAPI.md
Expand Up @@ -1155,7 +1155,7 @@ Note that this transform is implicit when using a string as a value to a key, wh
**Type:** standardTransformFunction

**Description:** Parses a number into a string. If the input is not a number, `undefined` will be returned.
Can optionally provide a `scale` which denotes the maximum number of decimal places to round the number to. Trailing 0s are omitted and numbers are rounded towards +∞ (i.e 0.5 -> 1, -0.5 -> 0).
Can optionally provide a `scale` which denotes the maximum number of decimal places to round the number to. Trailing 0s are omitted and numbers are rounded away from 0 (i.e 0.5 -> 1, -0.5 -> -1).
If the `scale` value is not numerical or is `NaN`, it is treated as though it were not specified at all.

**Invertibility:** Partly invertible. It is invertible when its domain is restricted to numbers.
Expand Down

0 comments on commit b4afc51

Please sign in to comment.