Re: Postgres int rounding - Mailing list pgsql-bugs

From Michael Richards
Subject Re: Postgres int rounding
Date
Msg-id 3A71122E.000195.13213@frodo.searchcanada.ca
Whole thread Raw
Responses Re: Re: Postgres int rounding
List pgsql-bugs
Is postgres going to use the scientific method of rounding or just
the simple one? Or even make it configurable. As I recall, the
scientific method says that 4.5 should be rounded to 4 and 5.5 should
be rounded to 6. The idea was that even numbers were easier to work
with and rounding all the x.5 numbers up as the common method says
will eventually skew your average. Rounding evens down and odds up
would probably generate a number of bug reports from people who are
not aware of this though...

-Michael

> The fact that 5*27.81*100 != 27.81*100*5 is certainly a
> garden-variety floating-point roundoff error.  However, I think
> Max has a fair complaint here: it seems float-to-int8 conversion
> is truncating, not rounding like the other conversions to integer
> do.
>
> regression=# select 4.7::float8::int4;
> ?column?
> ----------
> 5
> (1 row)
>
> regression=# select 4.7::float8::int8;
> ?column?
> ----------
> 4
> (1 row)
>
> Seems to me this is a bug we should fix.

_________________________________________________________________
     http://fastmail.ca/ - Fast Free Web Email for Canadians

pgsql-bugs by date:

Previous
From: "Robert B. Easter"
Date:
Subject: Re: BUG in postgres mathematic
Next
From: "Robert B. Easter"
Date:
Subject: Re: BUG in postgres mathematic