[prev in list] [next in list] [prev in thread] [next in thread] 

List:       postgresql-general
Subject:    Re: [GENERAL] Strange round behaviour w/ more than 2 decimals
From:       Peter Wiersig <peter () friesenpeter ! de>
Date:       2007-07-11 15:01:25
Message-ID: 20070711150125.GA18158 () london087 ! server4you ! de
[Download RAW message or body]

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

---------------------------(end of broadcast)---------------------------
TIP 4: Have you searched our list archives?

               http://archives.postgresql.org/
[prev in list] [next in list] [prev in thread] [next in thread] 

Configure | About | News | Add a list | Sponsored by KoreLogic