Re: About PostgreSQL's limit on arithmetic operations

Поиск
Список
Период
Сортировка
От Martijn van Oosterhout
Тема Re: About PostgreSQL's limit on arithmetic operations
Дата
Msg-id 20040929114311.GC5152@svana.org
обсуждение исходный текст
Ответ на Re: About PostgreSQL's limit on arithmetic operations  (Shridhar Daithankar <shridhar@frodo.hserus.net>)
Список pgsql-general
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.

Вложения

В списке pgsql-general по дате отправления:

Предыдущее
От: "Najib Abi Fadel"
Дата:
Сообщение: Re: Multiple Rules :: Postgres Is confused !!
Следующее
От: Martijn van Oosterhout
Дата:
Сообщение: Re: Multiple Rules :: Postgres Is confused !!