Re: INT8 / float casting question - Mailing list pgsql-sql

From Adrian Klaver
Subject Re: INT8 / float casting question
Date
Msg-id 5453AAEC.8050505@aklaver.com
Whole thread Raw
In response to INT8 / float casting question  (Filip Rembiałkowski <filip.rembialkowski@gmail.com>)
List pgsql-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



pgsql-sql by date:

Previous
From: Julien Cigar
Date:
Subject: Re: best strategy for searching large text fields
Next
From: Adrian Klaver
Date:
Subject: Re: INT8 / float casting question