Skip site navigation (1) Skip section navigation (2)

Re: INTEGER range ("-2147483648" is not accepted.)

From: Thom Brown <thombrown(at)gmail(dot)com>
To: Satoshi Nagayasu <satoshi(dot)nagayasu(at)gmail(dot)com>
Cc: pgsql-docs(at)postgresql(dot)org
Subject: Re: INTEGER range ("-2147483648" is not accepted.)
Date: 2010-06-22 08:36:30
Message-ID: AANLkTikX89l8iqkpcAJvxlJl5fP7dvyhmrHU8oer-lfY@mail.gmail.com (view raw or flat)
Thread:
Lists: pgsql-docs
2010/6/22 Satoshi Nagayasu <satoshi(dot)nagayasu(at)gmail(dot)com>:
> Hi all,
>
> I've found a bit strange thing on the INTEGER range in the official manual.
>
> http://www.postgresql.org/docs/8.4/interactive/datatype-numeric.html
>
> According to the official manual, the INTEGER range is "-2147483648 to +2147483647".
> However, my example in below shows that "-2147483648" is not accepted.
>
> Is this correct? Any suggestions?
>
> Regards,
>
> ---------------------------------------------------------------------
> template1=# SELECT version();
>                                                  version
> ------------------------------------------------------------------------------------------------------------
>  PostgreSQL 8.4.2 on i686-pc-linux-gnu, compiled by GCC gcc (GCC) 4.1.2 20071124 (Red Hat 4.1.2-42), 32-bit
> (1 row)
>
> template1=# SELECT -2147483647::integer;
>  ?column?
> -------------
>  -2147483647
> (1 row)
>
> template1=# SELECT -2147483648::integer;
> ERROR:  integer out of range
> template1=# SELECT +2147483648::integer;
> ERROR:  integer out of range
> template1=# SELECT +2147483647::integer;
>  ?column?
> ------------
>  2147483647
> (1 row)
>
> template1=#
> ---------------------------------------------------------------------
>

Hmm... yes, that's not what I'd expect either:

postgres=# SELECT -32768::smallint;
ERROR:  smallint out of range
postgres=# SELECT -9223372036854775808::bigint;
ERROR:  bigint out of range

I think those min values are all out by 1.

Thom

In response to

Responses

pgsql-docs by date

Next:From: Magnus HaganderDate: 2010-06-22 08:44:42
Subject: Re: INTEGER range ("-2147483648" is not accepted.)
Previous:From: Satoshi NagayasuDate: 2010-06-22 08:27:47
Subject: INTEGER range ("-2147483648" is not accepted.)

Privacy Policy | About PostgreSQL
Copyright © 1996-2014 The PostgreSQL Global Development Group