PSA: Postgres has extra_float_digits
Markus Demleitner
msdemlei at ari.uni-heidelberg.de
Thu Dec 10 09:58:44 CET 2020
Dear DAL implementors,
While this may be common knowledge given there is a fairly prominent
warning in the Postgres docs, I have to admit it's eluded me up to
now:
Postgres by default swallows least significant bits in the
mantissas of floats over its normal wire protocol.
This has recently been a bit of an embarrassment to me
(https://blog.g-vo.org/the-case-of-the-disappearing-bits/), and so I
thought it might be a good idea to send a heads-up to others who are
writing code serving science data through postgres. The TL;DR is:
If you want to serve out bit-exact floats from your Postgres, make
sure it runs with extra_float_digits=3 set in one way or another.
-- Markus
(who'd be curious if other RDMSes have similar practices; sqlite, for
one, doesn't seem to according to a quick experiment I've just run).
More information about the dal
mailing list