Re: About PostgreSQL's limit on arithmetic operations - Mailing list pgsql-general

From Shridhar Daithankar
Subject Re: About PostgreSQL's limit on arithmetic operations
Date
Msg-id 200409291651.31091.shridhar@frodo.hserus.net
Whole thread Raw
In response to Re: About PostgreSQL's limit on arithmetic operations  (Devrim GUNDUZ <devrim@gunduz.org>)
Responses Re: About PostgreSQL's limit on arithmetic operations  (Martijn van Oosterhout <kleptog@svana.org>)
Re: About PostgreSQL's limit on arithmetic operations  (Guy Fraser <guy@incentre.net>)
List 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

pgsql-general by date:

Previous
From: Marco Colombo
Date:
Subject: Re: Null comparisons (was Re: checksum)
Next
From: "Najib Abi Fadel"
Date:
Subject: Re: Multiple Rules :: Postgres Is confused !!