Skip to content

Commit 7c4fd3f

Browse files
committed
Improved jsdocs
1 parent 226daaa commit 7c4fd3f

1 file changed

Lines changed: 19 additions & 2 deletions

File tree

src/math/RoundTo.js

Lines changed: 19 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -5,13 +5,30 @@
55
*/
66

77
/**
8-
* Round a value to a given decimal place.
8+
* Round a value to the given precision.
9+
*
10+
* For example:
11+
*
12+
* ```javascript
13+
* RoundTo(123.456, 0) = 123
14+
* RoundTo(123.456, 1) = 120
15+
* RoundTo(123.456, 2) = 100
16+
* ```
17+
*
18+
* To round the decimal, i.e. to round to precision, pass in a negative `place`:
19+
*
20+
* ```javascript
21+
* RoundTo(123.456789, 0) = 123
22+
* RoundTo(123.456789, -1) = 123.5
23+
* RoundTo(123.456789, -2) = 123.46
24+
* RoundTo(123.456789, -3) = 123.457
25+
* ```
926
*
1027
* @function Phaser.Math.RoundTo
1128
* @since 3.0.0
1229
*
1330
* @param {number} value - The value to round.
14-
* @param {integer} [place=0] - The place to round to.
31+
* @param {integer} [place=0] - The place to round to. Positive to round the units, negative to round the decimal.
1532
* @param {integer} [base=10] - The base to round in. Default is 10 for decimal.
1633
*
1734
* @return {number} The rounded value.

0 commit comments

Comments
 (0)