On Mon, 1 Mar 2004, Philipp Matthias Hahn wrote:

> Peter Eisentraut wrote:
> > 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.
>
> No, see program and its results below.

Postgresql uses rint/rintf to do the rounding not round/roundf so you're
comparing apples and oranges (specifically round/roundf explicitly do not
honor the rounding direction)

----
>From my system man pages:

       double rint(double x);
       float rintf(float x);
       long double rintl(long double x);

DESCRIPTION

The nearbyint functions round their argument to an integer value in
floating point format, using the current rounding direction and without
raising the inexact exception.

The rint functions do the same, but will raise the inexact exception when
the result differs in value from the argument.


       double round(double x);
       float roundf(float x);
       long double roundl(long double x);

DESCRIPTION

These functions round x to the nearest integer, but round halfway cases
away from zero (regardless of the current rounding direction), instead of
to the nearest even integer like rint().


---------------------------(end of broadcast)---------------------------
TIP 9: the planner will ignore your desire to choose an index scan if your
      joining column's datatypes do not match

Reply via email to