PostgreSQL – Expressing the Largest Floating Point Value

postgresql

How to express the largest floating point value (for FLOAT8) in PostgreSQL?

I need it to replace 'Infinity'::FLOAT8 during conversion to jsonb field values, because json does not allow NaN and infinity values.

C++ has numeric_limits<double>::max(). Is there something equivalent in PostgreSQL?

(I'm using the latest PostgreSQL 11/12).

Best Answer

There is no constant for that in PostgreSQL, but if your architecture uses IEEE floating precision values, the maximum should be 1.7976931348623158e308.

Maybe it would be a good idea to use a value that's larger than any reasonable value, but obviously artificial, like 1e300.