Corresponding values ​​for -Infinity & Infinity in Postgres

In one case, do we need to pass values ​​for + infinity and -infection to Postgres DB?

What should be the appropriate value to consider.

If not 1, then please suggest the best match.

thank

+3


source to share


2 answers


In fact, you can use the data types +infinity

and -infinity

to FLOAT4

and FLOAT8

(ie, float

and double precision

) and timestamps.

regress=> SELECT FLOAT8 '+infinity', FLOAT8 '-infinity';
  float8  |  float8   
----------+-----------
 Infinity | -Infinity
(1 row)

      



For other types, either use a separate column, use the min / max values ​​for the type, or (where logically necessary) use null.

+6


source


add another column name "infinite", 1 means + infinity, -1 means "infinity" when you check numbers, check the column first.



it will save you a lot of time thinking about magic numbers or other things.

-1


source







All Articles