Re: About PostgreSQL's limit on arithmetic operations

From: Shridhar Daithankar <shridhar(at)frodo(dot)hserus(dot)net>
To: Devrim GUNDUZ <devrim(at)gunduz(dot)org>
Cc: PostgreSQL Mailing Lists-General <pgsql-general(at)postgresql(dot)org>
Subject: Re: About PostgreSQL's limit on arithmetic operations
Date: 2004-09-29 08:29:17
Message-ID: 200409291359.17494.shridhar@frodo.hserus.net
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-general

On Wednesday 29 Sep 2004 1:11 pm, Devrim GUNDUZ wrote:
> Hi,
>
> We were performing some tests on PostgreSQL and found that it fails on the
> following query:
>
> SELECT 512*18014398509481984 AS result;
>
> and the result is:
>
> result
> ----------------------
> -9223372036854775808
>
> It should be 9223372036854775808... This is PostgreSQL 7.4.5 on Fedora
> Core 2.

shridhar(at)ps0499:~$ psql template1
Welcome to psql 8.0.0beta2, the PostgreSQL interactive terminal.

Type: \copyright for distribution terms
\h for help with SQL commands
\? for help with psql commands
\g or terminate with semicolon to execute query
\q to quit

template1=# SELECT 512*18014398509481984 AS result;
result
----------------------
-9223372036854775808
(1 row)

template1=# SELECT 512*18014398509481984::bigint AS result;
result
----------------------
-9223372036854775808
(1 row)

template1=# SELECT 512*18014398509481984::numeric(20) AS result;
result
---------------------
9223372036854775808
(1 row)

template1=# select version();
version
-----------------------------------------------------------------------------
PostgreSQL 8.0.0beta2 on i686-pc-linux-gnu, compiled by GCC gcc (GCC) 3.3.4
(1 row)

Shridhar

In response to

Responses

Browse pgsql-general by date

  From Date Subject
Next Message Sim Zacks 2004-09-29 08:32:23 sql script confusion
Previous Message Devrim GUNDUZ 2004-09-29 07:41:43 About PostgreSQL's limit on arithmetic operations