Re: Cast double precision to integer & check for overflow - Mailing list pgsql-general

From Jasen Betts
Subject Re: Cast double precision to integer & check for overflow
Date
Msg-id ke268p$ab2$1@gonzo.reversiblemaps.ath.cx
Whole thread Raw
In response to Cast double precision to integer & check for overflow  (Ian Pilcher <arequipeno@gmail.com>)
List pgsql-general
On 2013-01-26, Ian Pilcher <arequipeno@gmail.com> wrote:
> I need to cast a double precision into an integer, and I want to check
> that the value will actually fit (modulo rounding).
>
> Coming from a C/Java background, this seems like something that should
> be utterly trivial.  In my searching, however, I can't seem to find any
> SQL equivalent of INT_MAX, Integer.MAX_VALUE, etc.
>
> Do I have to hard-code this value?

yes, I think so, the documentation lists the limits here:

http://www.postgresql.org/docs/9.2/interactive/datatype-numeric.html

They are most unlikely to ever change. A new type would probably be added
instead.

--
⚂⚃ 100% natural

pgsql-general by date:

Previous
From: Steve Clark
Date:
Subject: Re: noobie question
Next
From: pamkiki
Date:
Subject: Re: Temporary schemas