Re: Strange round behaviour w/ more than 2 decimals

From: Peter Wiersig <peter(at)friesenpeter(dot)de>
To: pgsql-general(at)postgresql(dot)org
Subject: Re: Strange round behaviour w/ more than 2 decimals
Date: 2007-07-11 15:01:25
Message-ID: 20070711150125.GA18158@london087.server4you.de
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: 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

In response to

Browse pgsql-general by date

  From Date Subject
Next Message Tom Lane 2007-07-11 15:07:40 Re: Strange round behaviour w/ more than 2 decimals
Previous Message David Gardner 2007-07-11 14:22:25 Re: odbc parameters