Re: Strange round behaviour w/ more than 2 decimals

Поиск
Список
Период
Сортировка
От Peter Wiersig
Тема Re: Strange round behaviour w/ more than 2 decimals
Дата
Msg-id 20070711150125.GA18158@london087.server4you.de
обсуждение исходный текст
Ответ на Strange round behaviour w/ more than 2 decimals  ("Fernando Madruga Pinheiro" <fernando.madrugapinheiro@gmail.com>)
Список pgsql-general
On Wed, Jul 11, 2007 at 09:50:25AM -0300, Fernando Madruga Pinheiro wrote:
>  Hi. I'm having some strange round behaviour when using 4 decimals.
>
>  If I use ROUND(1.8947, 2), it should return 1.90, but it does return 1.89.

I asked my math teacher a similar question back in 7th grade:

If you round 1.8947 to 1.89 the error is 0.0047. If you round
1.8947 to 1.90 the error is 0.0053.

My numbers where 1.49 and the rounding I proposed was: round to 1
decimals, round to 0 decimals to get 2 out of 1.49. I think he is
correct and that the postgresql function is also correct.

Peter

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

Предыдущее
От: "A. Kretschmer"
Дата:
Сообщение: Re: odbc parameters
Следующее
От: Tom Lane
Дата:
Сообщение: Re: Strange round behaviour w/ more than 2 decimals