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 11:21:30
Message-ID: 200409291651.31091.shridhar@frodo.hserus.net
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-general

On Wednesday 29 Sep 2004 2:25 pm, Devrim GUNDUZ wrote:
> > template1=# SELECT 512*18014398509481984::numeric(20) AS result;
> > result
> > ---------------------
> > 9223372036854775808
> > (1 row)
>
> Ok, I got the same result in 7.4.5... But... Why do we have to cast it
> into numeric? The results from other databases shows that they can perform
> it without casting...

Probably because the normal integer is 4 bytes long and bigint is 8 bytes
long. The value above is exactly 2^63 at which a 8 bytes long signed bigint
should flip sign/overflow. I am still puzzled with correct value and negative
sign..

For arbitrary precision integer, you have to use numeric. It is not same as
oracle.

Furthermore if your number fit in range, then numbers like precision(4,0) in
oracle to smallint in postgresql would buy you huge speed
improvement(compared to postgresql numeric I mean)

Please correct me if I am wrong..

Shridhar

In response to

Responses

Browse pgsql-general by date

  From Date Subject
Next Message Najib Abi Fadel 2004-09-29 11:40:19 Re: Multiple Rules :: Postgres Is confused !!
Previous Message Marco Colombo 2004-09-29 11:05:20 Re: Null comparisons (was Re: checksum)