repl.txt (680B)
1 2 {{alias}}( x, n ) 3 Rounds a numeric value to the nearest multiple of `10^n`. 4 5 When operating on floating-point numbers in bases other than `2`, rounding 6 to specified digits can be inexact. 7 8 Parameters 9 ---------- 10 x: number 11 Input value. 12 13 n: integer 14 Integer power of 10. 15 16 Returns 17 ------- 18 y: number 19 Rounded value. 20 21 Examples 22 -------- 23 // Round to 2 decimal places: 24 > var y = {{alias}}( 3.14159, -2 ) 25 3.14 26 27 // If `n = 0`, standard round behavior: 28 > y = {{alias}}( 3.14159, 0 ) 29 3.0 30 31 // Round to nearest thousand: 32 > y = {{alias}}( 12368.0, 3 ) 33 12000.0 34 35 36 See Also 37 -------- 38