From: | Adrian Klaver <adrian(dot)klaver(at)aklaver(dot)com> |
---|---|
To: | Filip Rembiałkowski <filip(dot)rembialkowski(at)gmail(dot)com>, Community PostgreSQL <pgsql-sql(at)postgresql(dot)org> |
Subject: | Re: INT8 / float casting question |
Date: | 2014-10-31 15:29:48 |
Message-ID: | 5453AAEC.8050505@aklaver.com |
Views: | Raw Message | Whole Thread | Download mbox | Resend email |
Thread: | |
Lists: | 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(dot)klaver(at)aklaver(dot)com
From | Date | Subject | |
---|---|---|---|
Next Message | Adrian Klaver | 2014-10-31 15:45:47 | Re: INT8 / float casting question |
Previous Message | Julien Cigar | 2014-10-31 15:17:10 | Re: best strategy for searching large text fields |