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