Crate irox_fixedmath

Source
Expand description

Fixed-precision mathematics.

Structs§

FixedI32
Fixed precision i32 - upper 16 bits is value, lower 16 bits are the fractional portion of the value. Each fractional portion is 1/u16::MAX ~= 1.5259e-5 or 0.000_015_259, or about 15.3 micro, and can accurately represent SI-prefixes: milli/1e-3. The whole portion can represent i16::MIN (-32768) -> i16::MAX (32_727)
FixedI64
Fixed precision i64 - upper 32 bits is value, lower 32 bits are the fractional portion of the value. Each fractional portion is 1/u32::MAX ~= 2.328306e-10 or 0.000_000_000_238_306, or about 238.3 pico, and can accurately represent SI-prefixes milli/1e-3, micro/1e-6, and nano/1e-9. The whole portion can represent i32::MIN (-2_147_483_648) -> i32::MAX (2_147_483_647)
FixedI128
Fixed precision u128 - upper 64 bits is value, lower 64 bits are the fractional portion of the value. Each fractional portion is 1/i64::MAX ~= 5.4210e-20 or 0.000_000_000_000_000_000_054_210, or about 54.2 zepto, and can accurately represent SI-prefixes milli/1e-3, micro/1e-6, nano/1e-9, pico/1e-12, femto/1e-15, and atto/1e-18. This is probably overkill for what you need. The whole portion can represent i64::MIN (-9_223_372_036_854_775_808) -> i64::MAX (9_223_372_036_854_775_807)
FixedU32
Fixed precision u32 - upper 16 bits is value, lower 16 bits are the fractional portion of the value. Each fractional portion is 1/u16::MAX ~= 1.5259e-5 or 0.000_015_259, or about 15.3 micro, and can accurately represent SI-prefixes: milli/1e-3. The whole portion can represent 0 -> u16::MAX (65_535)
FixedU64
Fixed precision u64 - upper 32 bits is value, lower 32 bits are the fractional portion of the value. Each fractional portion is 1/u32::MAX ~= 2.328306e-10 or 0.000_000_000_238_306, or about 238.3 pico, and can accurately represent SI-prefixes milli/1e-3, micro/1e-6, and nano/1e-9. The whole portion can represent 0 -> u32::MAX (4_294_967_295)
FixedU128
Fixed precision u128 - upper 64 bits is value, lower 64 bits are the fractional portion of the value. Each fractional portion is 1/u64::MAX ~= 5.4210e-20 or 0.000_000_000_000_000_000_054_210, or about 54.2 zepto, and can accurately represent SI-prefixes milli/1e-3, micro/1e-6, nano/1e-9, pico/1e-12, femto/1e-15, and atto/1e-18. This is probably overkill for what you need. The whole portion can represent 0 -> u64::MAX (1.84467E+19)

Traits§

AsFixedPoint
FloatExt