6 ms·
The complicated number encoding scheme you mentioned is a hexfloat: C has them too. Hexfloat can be really useful when you need precise/exact floating-point co
by profquail 4y ago
The complicated number encoding scheme you mentioned is a hexfloat: C has them too.
Hexfloat can be really useful when you need precise/exact floating-point constants for numerical methods. Without them, you end up having to do more-complicated hacks to preserve exact constant values when code gets compiled, or you have to live with compilers (sometimes) subtly altering constants.
I wish more languages supported hexfloats.
- BoppreH 4y agoThanks, I had never seen that before. But Concise Encoding did complicate them further by accepting commas as decimal separator.
- unwind 4y agoJust to clarify a bit what "C has them" means; the standard library string-to-float parsing function strtof() [1] support this format. You can also use them as floating-point literals in your code. [1]: https://linux.die.net/man/3/strtof https://linux.die.net/man/3/strtof
- formerly_proven 4y agoHexfloat is also vastly easier to parse from/to IEEE 752 format than decimal floats.