Like the question says. Converting to / from the (truncated) string representations can affect their precision. But storing them in other formats like pickle makes them unreadable (yes, I want this too).
How can I store floating point numbers in text without losing precision?
Store it in binary or a power thereof.
>>> (3.4).hex()
'0x1.b333333333333p+1'
>>> float.fromhex('0x1.b333333333333p+1')
3.4
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