Re: Rounding to even for numeric data type

Поиск
Список
Период
Сортировка
От James Cloos
Тема Re: Rounding to even for numeric data type
Дата
Msg-id m3sicna8gg.fsf@carbon.jhcloos.org
обсуждение исходный текст
Ответ на Re: Rounding to even for numeric data type  (Michael Paquier <michael.paquier@gmail.com>)
Ответы Re: Rounding to even for numeric data type  (Michael Paquier <michael.paquier@gmail.com>)
Список pgsql-hackers
>>>>> "MP" == Michael Paquier <michael.paquier@gmail.com> writes:

MP> So, attached is a patch that does 1) and 2) to make clear to the
MP> user how numeric and double precision behave regarding rounding.
MP> I am adding it to CF 2015-06 to keep track of it...

Given that the examples show -2.5 rounds to -3, the IEEE term is
roundTiesToAway, and the typical conversational english is round ties
away from zero.

RoundUp means mean towards +Infinity.

754 specifies that for decimal, either roundTiesToEven or roundTiesToAway
are acceptable defaults, and which of the two applies is language dependent.
Does ANSI SQL say anything about how numeric should round?

In general, for decimals (or anything other than binary), there are
twelve possible roundings:
ToEven ToOdd AwayFromZero ToZero Up DownTiesToEven TiesToOdd TiesAwayFromZero TiesToZero TiesUp TiesDown

(Up is the same as ceil(3), Down as floor(3).)

-JimC
-- 
James Cloos <cloos@jhcloos.com>         OpenPGP: 0x997A9F17ED7DAEA6



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

Предыдущее
От: Tom Lane
Дата:
Сообщение: Re: Relation extension scalability
Следующее
От: Andres Freund
Дата:
Сообщение: Re: Relation extension scalability