fuzion-lang.dev — The Fuzion Language Portal
JavaScript seems to be disabled. Functionality is limited.
Fuzion
•
Idioms
•
Idiom # 248: Construct a 64-bit floating-point value
Idiom # 248: Construct a 64-bit floating-point value
See
programming-idioms.org
:
Code
NYI: this might become a library function in the future, see
#3248
d := ((s ? u64.one << 63 : u64.zero) | (e << (f64.significand_bits - 1).as_u64) | m).cast_to_f64
What are effects?
Running Example
ex248 is test_vals := [(false, (u64 0), (u64 1023)), (false, (u64 0), (u64 1024)), (true , (u64 0), (u64 1023) + 16), (true , (u64 66), (u64 7)), (true , ((f64 1234).mantissa & f64.mantissa_mask), (f64 1234).exponent_biased.as_u64), (false, (u64 1407374883553280), (u64 1028))] for t in test_vals do (s,m,e) := t d := ((s ? u64.one << 63 : u64.zero) | (e << (f64.significand_bits - 1).as_u64) | m).cast_to_f64 say "s=$s m=$m e=$e : $d"
What are effects?
last changed: 2024-07-01
next: Idiom # 249: Declare and assign multiple variables