#fixed #numbers #point

no-std fixed-point

Fixed point numbers

3 stable releases

1.0.2 May 20, 2022
1.0.1 May 19, 2022

#58 in #fixed


Used in mpu6000

MIT/Apache

8KB
152 lines

Fixed-point numbers

fixed-point numbers use constant D as decimal digit length e.g. fixed!(1.1i16, 2) will declare number as 110i16

  • Define a constant fixed-point number

    use fixed_point::{fixed, FixedPoint};
    const FIXED_POINT: FixedPoint<u16, 3> = fixed!(0.25, 3);
    
  • Define a fixed-point variable

    use fixed_point::fixed;
    let decimal = fixed!(-1.1i16, 2);
    
  • Define a implicit precision fixed-point variable

    use fixed_point::fixed;
    let decimal = fixed!(-1.1i16);
    

Dependencies

~1.5MB
~39K SLoC