News for hackers. Stuff that matters.
Re:9999999999999999.0 – 9999999999999998.0 by moefh on Thursday January 11, 2024 @01:22PM (#38956357)
The `real` type (float32) only has 24 bits of precision. So converting `9999999999999999.0` or `10000000000000000` or even `10000000300000000` yields the 32-bit float `10000000272564224`.

For some reason Postgres prints it as `10000000300000000`. It uses a heuristic to print a "pretty" number that converts to the actual stored value, and it's not smart enough to give `10000000000000000`. Some heuristic like this is needed so something like `0.3` doesn't print the actual stored value of `0.300000011920928955078125`, which would be confusing.

You can check all this here: https://www.h-schmidt.net/FloatConverter/IEEE754.html

There are no comments on this comment yet.