Strange round behaviour w/ more than 2 decimals
От
Fernando Madruga Pinheiro
Тема
Strange round behaviour w/ more than 2 decimals
Дата
Msg-id
979602370707110550t6498b049h8bf922421f868ea1@mail.gmail.com
Список
Дерево обсуждения
Strange round behaviour w/ more than 2 decimals "Fernando Madruga Pinheiro" <fernando.madrugapinheiro@gmail.com>
Re: Strange round behaviour w/ more than 2 decimals Peter Wiersig <peter@friesenpeter.de>
Re: Strange round behaviour w/ more than 2 decimals Tom Lane <tgl@sss.pgh.pa.us>
Re: Strange round behaviour w/ more than 2 decimals "Fernando Madruga Pinheiro" <fernando.madrugapinheiro@gmail.com>
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. Rounding to 3 decimal places, then 2 (eg.: ROUND(ROUND(1.8947, 3), 2) ) then I get 1.90!
This way, when rounding, ROUND is considering only decimal places parameter + 1 to determine which is the rounding (ROUND(1.8951, 2) returns 1.90).
I've tested in 8.1.3 and 8.2.4.
Is it expected to work this way? There's a way to "force" the round to consider all the decimal places?
Thanks,
Fernando Pinheiro
If I use ROUND(1.8947, 2), it should return 1.90, but it does return 1.89. Rounding to 3 decimal places, then 2 (eg.: ROUND(ROUND(1.8947, 3), 2) ) then I get 1.90!
This way, when rounding, ROUND is considering only decimal places parameter + 1 to determine which is the rounding (ROUND(1.8951, 2) returns 1.90).
I've tested in 8.1.3 and 8.2.4.
Is it expected to work this way? There's a way to "force" the round to consider all the decimal places?
Thanks,
Fernando Pinheiro
В списке pgsql-general по дате отправления