4 ms·
Yep. And C and C++ now have a hexfloat format that lets you write a float exactly in terms of the mantissa and exponent. For the value `8.0`, you can write it
by a_e_k 3y ago
Yep. And C and C++ now have a hexfloat format that lets you write a float exactly in terms of the mantissa and exponent. For the value `8.0`, you can write it as `0x1p3`. (It's kind of weird in that the unbiased exponent is in decimal while the mantissa is in hex, so `1024.0` could be written `0x1p10`.)
The printf/scanf specifier, by the way, is `%a`.
- taeric 3y agoThanks! I was actually surprised at not knowing how to get that representation. In particular, I was surprised that Common Lisp has a way to get binary for integers, but I don't see how to get the float binary printed out. Granted, I don't imagine this comes in necessary that often.