input value
integer power of 10
rounded value
// Round a value to 4 decimal places:
var v = floorn( 3.141592653589793, -4 );
// returns 3.1415
// If n = 0, `floorn` behaves like `floor`:
var v = floorn( 3.141592653589793, 0 );
// returns 3.0
// Round a value to the nearest thousand:
var v = floorn( 12368.0, 3 );
// returns 12000.0
Rounds a numeric value to the nearest multiple of
10^n
toward negative infinity.Notes
2
, rounding to specified digits can be inexact.