Please noteNote that FixedU128
is not a floating point type. It represents floating point numbers using u128
type with 18 digits of precision. This means that the last 18 digits of any number are taken to be the fractional part and the rest are taken to be the integer part.
This way, we can represent 1.23
as 1_230_000_000_000_000_000
. Where 230_000_000_000_000_000
is the fractional part and 1
is the integer part.
So 500000000000000000
is the correct value. You can see that by printing it using the debug format
log::info!("value of integer is {:?}", fixed_value);