agora inbox for pgsql-sql@postgresql.org
help / color / mirror / Atom feedFrom: Adrian Klaver <adrian.klaver@aklaver.com>
To: Filip RembiaĆkowski <filip.rembialkowski@gmail.com>
To: Community PostgreSQL <pgsql-sql@postgresql.org>
Subject: Re: INT8 / float casting question
Date: Fri, 31 Oct 2014 08:45:47 -0700
Message-ID: <5453AEAB.5020001@aklaver.com> (raw)
In-Reply-To: <CAP_rwwksWXsxon-fbG5itzXPjCHAY9cXoKH139jVV1J3J5w+8A@mail.gmail.com>
References: <CAP_rwwksWXsxon-fbG5itzXPjCHAY9cXoKH139jVV1J3J5w+8A@mail.gmail.com>
List-Unsubscribe: <mailto:majordomo@postgresql.org?body=unsub%20pgsql-sql>
On 10/31/2014 07:58 AM, Filip RembiaĆkowski wrote:
> psql.bin (9.3.4, server 9.3.5)
> Type "help" for help.
>
> dev=# select (2^63-1)::INT8;
> ERROR: bigint out of range
>
>
>
>
>
> Does it HAVE to be so?
No, figured it out:
test=# select ((2^63-1)::numeric);
numeric
---------------------
9223372036854780000
is rounding up.
To get what you want:
test=# select (2^63::numeric-1)::int8;
int8
---------------------
9223372036854775807
(1 row)
>
>
> http://en.wikipedia.org/wiki/9223372036854775807
>
>
>
> Thanks
> Filip
>
>
--
Adrian Klaver
adrian.klaver@aklaver.com
--
Sent via pgsql-sql mailing list (pgsql-sql@postgresql.org)
To make changes to your subscription:
http://www.postgresql.org/mailpref/pgsql-sql
view thread (4+ messages)
Message-ID: <5453AEAB.5020001@aklaver.com>
Permalink: ../5453AEAB.5020001@aklaver.com/
Also on: postgresql.org/message-id/5453AEAB.5020001@aklaver.com
reply
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Reply to all the recipients using the --to and --cc options:
reply via email
To: pgsql-sql@postgresql.org
Cc: adrian.klaver@aklaver.com, filip.rembialkowski@gmail.com
Subject: Re: INT8 / float casting question
In-Reply-To: <5453AEAB.5020001@aklaver.com>
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
This inbox is served by agora; see mirroring instructions
for how to clone and mirror all data and code used for this inbox