On Wed, Sep 29, 2004 at 04:51:30PM +0530, Shridhar Daithankar wrote:
> 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..
Because in signed integer arithmatic the negative numbers go one
further than the positive numbers. So the largest positive number is
2^63-1 and the largest negative number is -2^63.
Or put it another way: -2^63 = +2^63. It's the far end of the loop,
exactly opposite the zero.
> For arbitrary precision integer, you have to use numeric. It is not same as
> oracle.
I would say that it should produce an overflow error rather than just
returning the wrong answer, but that's not my call...
Have a nice day,
--
Martijn van Oosterhout <kleptog@svana.org> http://svana.org/kleptog/
> Patent. n. Genius is 5% inspiration and 95% perspiration. A patent is a
> tool for doing 5% of the work and then sitting around waiting for someone
> else to do the other 95% so you can sue them.