bits_of
lib callCapy
function bits_of(value : f32) u32 function bits_of(value : f64) u64
Description
bits_of() reinterprets, it does not convert: bits_of(1.0) is 4607182418800017408, the encoding of 1.0, not 1. Use it to hash floats, to compare them bit for bit, or to store them in an integer field. f64_from_bits() and f32_from_bits() reverse it.
Parameters
value : a floating-point number
Return Values
The IEEE 754 bit pattern of value: u32 for f32, u64 for f64.
Example
Capy
print(bits_of(1.0), " ", bits_of(f32(1.0)), " ", bits_of(-0.0) != bits_of(0.0), "\n")
Output
4607182418800017408 1065353216 true