Purpose of rscale/dscale in NUMERIC?

Поиск
Список
Период
Сортировка
От Tom Lane
Тема Purpose of rscale/dscale in NUMERIC?
Дата
Msg-id 17150.1033507490@sss.pgh.pa.us
обсуждение исходный текст
Список pgsql-hackers
What is the reason for maintaining separate rscale and dscale values in
numeric variables?

I am finding that this arrangement leads to some odd results, for
example this:

regression=# select (exp(ln(2.0)) - 2.0);     ?column?
----------------------0.0000000000000000
(1 row)

regression=# select (exp(ln(2.0)) - 2.0) * 100000;     ?column?
----------------------0.0000000000000010
(1 row)

The difference between rscale and dscale allows some "hidden" digits to
be carried along in an expression result, and then possibly exposed
later.  This seems pretty nonintuitive for an allegedly exact
calculational datatype.  ISTM the policy should be "what you see is what
you get" - no hidden digits.  That would mean there's no need for
separating rscale and dscale, so I'm wondering why they were put in
to begin with.
        regards, tom lane


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

Предыдущее
От: Andrew Sullivan
Дата:
Сообщение: Re: table lock and record lock
Следующее
От: "scott.marlowe"
Дата:
Сообщение: Re: table lock and record lock