Can all IEEE 754 32 bit floating point numbers be represented exactly by a 64 bit floating point number? Stated another way, is a cast from f32 to f64 ever rounded?
Can all IEEE 754 32 bit floating point numbers be represented exactly by a 64 bit floating point number?
Yes. All numeric values of binary32 are in binary64.
Stated another way, is a cast from f32 to f64 ever rounded?
Not usually. Various language like C allow intermediate 32-bit FP calculations to employ wider math and so a cast may narrow (round) results. Yet if the value was truly f32, no rounding error would occur going to f64.
Aside:
The Not-a-number payload of a binary32 is 23 bits and that is fully encodable as a binary64, yet the detailed meaning of those is implementation dependent.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With