Re: [GENERAL] Cast double precision to integer & check for overflow

Поиск
Список
Период
Сортировка
От Alexander Gataric
Тема Re: [GENERAL] Cast double precision to integer & check for overflow
Дата
Msg-id 643RaZXgh5344M32@ca32.cms.usa.net
обсуждение исходный текст
Ответы Re: Cast double precision to integer & check for overflow
Список pgsql-general
Just cast to integer. Decimal portion will be lost.

Sent from my smartphone

----- Reply message -----
From: "Ian Pilcher" <arequipeno@gmail.com>
To: <pgsql-general@postgresql.org>
Subject: [GENERAL] Cast double precision to integer & check for overflow
Date: Sat, Jan 26, 2013 3:13 pm


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?

Thanks!

(And yes, I do feel stupid having to ask this question here.)

--
========================================================================
Ian Pilcher                                         arequipeno@gmail.com
Sometimes there's nothing left to do but crash and burn...or die trying.
========================================================================



--
Sent via pgsql-general mailing list (pgsql-general@postgresql.org)
To make changes to your subscription:
http://www.postgresql.org/mailpref/pgsql-general

В списке pgsql-general по дате отправления:

Предыдущее
От: Ian Pilcher
Дата:
Сообщение: Cast double precision to integer & check for overflow
Следующее
От: Ian Pilcher
Дата:
Сообщение: Re: Cast double precision to integer & check for overflow