pub fn stochastic(value: f64, scale: i8) -> f64Expand description
Round half randomly up or down.
Round value to accuracy defined by scale
rounding half randomly up or down.
Positive scale defines the number of decimal digits in the result
while negative scale rounds to a whole number and defines the number
of trailing zeroes in the result.
§Arguments
value- value to roundscale- result accuracy
§Examples
use math::round;
let rounded = round::stochastic(3.14159, 3);
assert_eq!(rounded == 3.141 || rounded == 3.142, true);use math::round;
let rounded = round::stochastic(3456., -2);
assert_eq!(rounded == 3400. || rounded == 3500., true);