Strange round behaviour w/ more than 2 decimals

From: "Fernando Madruga Pinheiro" <fernando(dot)madrugapinheiro(at)gmail(dot)com>
To: pgsql-general(at)postgresql(dot)org
Subject: Strange round behaviour w/ more than 2 decimals
Date: 2007-07-11 12:50:25
Message-ID: 979602370707110550t6498b049h8bf922421f868ea1@mail.gmail.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-general

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

Responses

Browse pgsql-general by date

  From Date Subject
Next Message Zlatko Matic 2007-07-11 12:55:28 Re: odbc parameters
Previous Message Ludek Finstrle 2007-07-11 12:34:50 Re: odbc parameters