Re: NUMERIC private methods?

Поиск
Список
Период
Сортировка
От Bruce Momjian
Тема Re: NUMERIC private methods?
Дата
Msg-id 20150322040040.GI10795@momjian.us
обсуждение исходный текст
Ответ на Re: NUMERIC private methods?  (Tom Lane <tgl@sss.pgh.pa.us>)
Ответы Re: NUMERIC private methods?  (Andrew Gierth <andrew@tao11.riddles.org.uk>)
Список pgsql-hackers
On Thu, Dec 18, 2014 at 11:51:12PM -0500, Tom Lane wrote:
> If you're doing any sort of higher math or statistics, I stand by my
> statement that you'd better think rather than just blindly assume that
> numeric is going to be better for you.  A moment's fooling about finds
> this example, which is pretty relevant to the formula we started this
> thread with:
>
> regression=# select (1234::numeric/1235) * 1235;
>          ?column?
> ---------------------------
>  1234.00000000000000000100
> (1 row)
>
> regression=# select (1234::float8/1235) * 1235;
>  ?column?
> ----------
>      1234
> (1 row)
>
> What it boils down to is that numeric is great for storing given decimal
> inputs exactly, and it can do exact addition/subtraction/multiplication
> on those too, but as soon as you get into territory where the result is
> fundamentally inexact it is *not* promised to be better than float8.
> In fact, it's designed to be more or less the same as float8; see the
> comments in select_div_scale.

Based on the analysis above, I have written the attached patch to the
NUMERIC docs to mention this.

--
  Bruce Momjian  <bruce@momjian.us>        http://momjian.us
  EnterpriseDB                             http://enterprisedb.com

  + Everyone has their own god. +

Вложения

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

Предыдущее
От: Andrew Gierth
Дата:
Сообщение: debug_sortsupport GUC?
Следующее
От: Andrew Gierth
Дата:
Сообщение: Re: NUMERIC private methods?