Re: Strange round behaviour w/ more than 2 decimals

Поиск
Список
Период
Сортировка
От Tom Lane
Тема Re: Strange round behaviour w/ more than 2 decimals
Дата
Msg-id 25402.1184166460@sss.pgh.pa.us
обсуждение исходный текст
Ответ на Strange round behaviour w/ more than 2 decimals  ("Fernando Madruga Pinheiro" <fernando.madrugapinheiro@gmail.com>)
Ответы Re: Strange round behaviour w/ more than 2 decimals  ("Fernando Madruga Pinheiro" <fernando.madrugapinheiro@gmail.com>)
Список pgsql-general
"Fernando Madruga Pinheiro" <fernando.madrugapinheiro@gmail.com> writes:
> If I use ROUND(1.8947, 2), it should return 1.90, but it does return 1.89.

Why do you consider that wrong?  It's the closest approximation.
Do you know of any other software that would produce 1.90 from a
similar query?

> Rounding to 3 decimal places, then 2 (eg.: ROUND(ROUND(1.8947, 3), 2) ) then
> I get 1.90!

Since ROUND() is a lossy process by definition, you cannot expect
that different multi-step paths will always yield the same result.

            regards, tom lane

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

Предыдущее
От: Peter Wiersig
Дата:
Сообщение: Re: Strange round behaviour w/ more than 2 decimals
Следующее
От: "Fernando Madruga Pinheiro"
Дата:
Сообщение: Re: Strange round behaviour w/ more than 2 decimals