Received: from maia.hub.org (maia-2.hub.org [200.46.204.251]) by mail.postgresql.org (Postfix) with ESMTP id 3893F6325DE for ; Tue, 22 Jun 2010 05:44:55 -0300 (ADT) Received: from mail.postgresql.org ([200.46.204.86]) by maia.hub.org (mx1.hub.org [200.46.204.251]) (amavisd-maia, port 10024) with ESMTP id 45499-01 for ; Tue, 22 Jun 2010 08:44:44 +0000 (UTC) X-Greylist: from auto-whitelisted by SQLgrey-1.7.6 Received: from fg-out-1718.google.com (fg-out-1718.google.com [72.14.220.155]) by mail.postgresql.org (Postfix) with ESMTP id A529C6325DA for ; Tue, 22 Jun 2010 05:44:44 -0300 (ADT) Received: by fg-out-1718.google.com with SMTP id d23so1258794fga.1 for ; Tue, 22 Jun 2010 01:44:42 -0700 (PDT) MIME-Version: 1.0 Received: by 10.239.135.2 with SMTP id b2mr415823hbb.206.1277196282342; Tue, 22 Jun 2010 01:44:42 -0700 (PDT) Received: by 10.239.159.145 with HTTP; Tue, 22 Jun 2010 01:44:42 -0700 (PDT) In-Reply-To: <4C207403.3080103@gmail.com> References: <4C207403.3080103@gmail.com> Date: Tue, 22 Jun 2010 10:44:42 +0200 Message-ID: Subject: Re: INTEGER range ("-2147483648" is not accepted.) From: Magnus Hagander To: Satoshi Nagayasu Cc: pgsql-docs Content-Type: text/plain; charset=ISO-8859-1 Content-Transfer-Encoding: quoted-printable X-Virus-Scanned: Maia Mailguard 1.0.1 X-Spam-Status: No, hits=-1.9 tagged_above=-5 required=5 tests=BAYES_00=-1.9, RCVD_IN_DNSWL_NONE=-0.0001 X-Spam-Level: X-Archive-Number: 201006/45 X-Sequence-Number: 5613 On Tue, Jun 22, 2010 at 10:27 AM, Satoshi Nagayasu wrote: > Hi all, > > I've found a bit strange thing on the INTEGER range in the official manua= l. > > http://www.postgresql.org/docs/8.4/interactive/datatype-numeric.html > > According to the official manual, the INTEGER range is "-2147483648 to +2= 147483647". > However, my example in below shows that "-2147483648" is not accepted. > > Is this correct? Any suggestions? > > template1=3D# SELECT -2147483648::integer; > ERROR: =A0integer out of range This gets parsed as "cast 2147483648 to integer, then take it negative". Which overflows, because it can only go up to 2147483647. What you want is: postgres=3D# select (-2147483648)::integer; int4 ------------- -2147483648 (1 row) --=20 Magnus Hagander Me: http://www.hagander.net/ Work: http://www.redpill-linpro.com/