Module actyx_sdk::types::fixnum_types [−][src]
Expand description
collection of useful types for use with FixNum
Example
use actyx_sdk::types::{FixNum, fixnum_types::U32};
// convert to fixed-point number with 32 bits fractional part, saturating on overflow
let a: FixNum<U32> = FixNum::<U32>::saturating(12345);
// convert it to a float
let f = a.to_num_checked::<f64>().unwrap();
assert_eq!(f, 12345f64);
// convert a float to fixed-point, wrapping around on overflow
let b: FixNum<U32> = FixNum::wrapping(13.7e250f64);