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

From Peter Wiersig
Subject Re: Strange round behaviour w/ more than 2 decimals
Date
Msg-id 20070711150125.GA18158@london087.server4you.de
Whole thread Raw
In response to Strange round behaviour w/ more than 2 decimals  ("Fernando Madruga Pinheiro" <fernando.madrugapinheiro@gmail.com>)
List 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 by date:

Previous
From: "A. Kretschmer"
Date:
Subject: Re: odbc parameters
Next
From: Tom Lane
Date:
Subject: Re: Strange round behaviour w/ more than 2 decimals