fn from()

in chrony-candm/src/common.rs [241:257]


    fn from(f: ChronyFloat) -> Self {
        let ChronyFloat(x) = f;

        let mut exp = (x >> FLOAT_COEF_BITS) as i32;
        if exp >= 1 << (FLOAT_EXP_BITS - 1) {
            exp -= 1 << FLOAT_EXP_BITS;
        }
        exp -= FLOAT_COEF_BITS as i32;

        let mut coef = (x % (1 << FLOAT_COEF_BITS)) as i32;

        if coef >= 1 << (FLOAT_COEF_BITS - 1) {
            coef -= 1 << FLOAT_COEF_BITS
        }

        (coef as f64) * 2.0f64.powi(exp)
    }