Re: WIP: rewrite numeric division

Поиск
Список
Период
Сортировка
От Tom Lane
Тема Re: WIP: rewrite numeric division
Дата
Msg-id 27542.1182263309@sss.pgh.pa.us
обсуждение исходный текст
Ответ на Re: WIP: rewrite numeric division  (Gregory Stark <stark@enterprisedb.com>)
Список pgsql-patches
Gregory Stark <stark@enterprisedb.com> writes:
> "Tom Lane" <tgl@sss.pgh.pa.us> writes:
>> Yeah, my proposed patch is schoolbook division.  I don't think I'd trust
>> Newton's method to give anything but a close approximation, which is
>> what we have in HEAD already.

> Well unless we start storing rational numbers it'll always be a limited to a
> finite number of decimals. The key is whether we can guarantee a lower bound
> on the number of accurate decimal places. As long as we can then we can keep
> going until the decimal places we're going to return are all accurate.

This is nonsense.  Consider an approximate division that gives

    ...123.999999999999999999...

You can keep generating 9's forever, but you'll never know whether the
accurate result of trunc() should be 123 or 124.  Unless you use a
method that gives you trustworthy digits to start with.

> It looks like multiplication can also generate incorrect results.

It can, but only if told to produce fewer digits than would be in the
exact result, so I'm not worried about that.

            regards, tom lane

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

Предыдущее
От: Magnus Hagander
Дата:
Сообщение: Re: Preliminary GSSAPI Patches
Следующее
От: Tom Lane
Дата:
Сообщение: Re: [HACKERS] 'Waiting on lock'