Skip to main content

snap_decimal

Function snap_decimal 

pub fn snap_decimal(value: f64, operands: &[f64]) -> f64
Expand description

value, a sum of operands or of whole multiples of them, as the decimal those operands make: rounded to the most places any of them is written with. Binary floats drift where decimals do not (0.1 + 0.2 is 0.30000000000000004, 7 × 0.1 is 0.7000000000000001), so a stepper or slider moved in tenths would otherwise land beside the value it shows and miss the end of its range. value is returned unchanged when an operand is not a short decimal.