Strange round behaviour w/ more than 2 decimals - Mailing list pgsql-general

From Fernando Madruga Pinheiro
Subject Strange round behaviour w/ more than 2 decimals
Date
Msg-id 979602370707110550t6498b049h8bf922421f868ea1@mail.gmail.com
Whole thread Raw
Responses 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>)
List 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

pgsql-general by date:

Previous
From: "A. Kretschmer"
Date:
Subject: Re: odbc parameters
Next
From: "Zlatko Matic"
Date:
Subject: Re: odbc parameters