Skip to main content

decimal_to_f32_rounded_once

Function decimal_to_f32_rounded_once 

Source
fn decimal_to_f32_rounded_once<D: DecimalType>(
    x: D::Native,
    scale: i8,
    unscaled: f64,
) -> f32
Expand description

As decimal_to_f64_rounded_once, but narrowing to f32 in one step. Rounding to f64 first and then to f32 rounds twice: a decimal just above an f32 midpoint can collapse onto that midpoint in f64, and round-half-even then sends it the wrong way.