agora inbox for pgsql-sql@postgresql.org  
help / color / mirror / Atom feed
From: 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:29:48 -0700
Message-ID: <5453AAEC.8050505@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?
>
>
> http://en.wikipedia.org/wiki/9223372036854775807

It seems to be not a problem with the number but the exponentiation and 
casting:

test=# create table bigint_test (int_fld int8);
CREATE TABLE
test=# insert into bigint_test values (9223372036854775807);
INSERT 0 1
test=# select * from bigint_test ;
        int_fld
---------------------
  9223372036854775807

test=# select 2^63-1;
        ?column?
----------------------
  9.22337203685478e+18
(1 row)

test=# select (2^63-1)::int8;
ERROR:  bigint out of range



>
>
>
> 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)  latest in thread

Message-ID: <5453AAEC.8050505@aklaver.com>
Permalink:  ../5453AAEC.8050505@aklaver.com/
Also on:    postgresql.org/message-id/5453AAEC.8050505@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: <5453AAEC.8050505@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