input value
integer power
base
rounded value
// Round a value to 4 decimal places:
var v = truncb( 3.141592653589793, -4, 10 );
// returns 3.1415
// If n = 0 or b = 1, `truncb` behaves like `trunc`:
var v = truncb( 3.141592653589793, 0, 2 );
// returns 3.0
// Round a value to the nearest multiple of two toward zero:
var v = truncb( 5.0, 1, 2 );
// returns 4.0
Rounds a numeric value to the nearest multiple of \(b^n\) toward zero.
Notes