Re: round(50.5) = 50

From: Peter Eisentraut <peter_e(at)gmx(dot)net>
To: Philipp Matthias Hahn <Philipp(dot)Hahn(at)informatik(dot)uni-oldenburg(dot)de>, pgsql-bugs(at)postgresql(dot)org
Subject: Re: round(50.5) = 50
Date: 2004-02-29 03:00:17
Message-ID: 200402290400.17831.peter_e@gmx.net
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-bugs

Philipp Matthias Hahn wrote:
> # SELECT round(5.5::float4),round(50.5::float4);
> round | round
> -------+-------
> 6 | 50
> (1 row)
>
> I think this is a bug, since I would expect 6 and 51.

The default rounding mode for floating point (determined by your C
library, mostly) it to round toward the closest even number. If you
are at all concerned abou that, you probably shouldn't be using
floating point, but rather numeric.

In response to

Responses

Browse pgsql-bugs by date

  From Date Subject
Next Message Peter Eisentraut 2004-02-29 03:01:19 Re: About Create Assertion
Previous Message Tom Lane 2004-02-29 02:08:38 Re: Optimizer problem with subselect.c?