Search Postgresql Archives

Re: [GENARAL] round() bug

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



Raymond O'Donnell wrote:
>>> Interestingly, I get different results (on both 9.1.4 and 9.3.0) on
>>> Windows:

>> I'm not particularly surprised that Windows is not being IEEE compliant, and
>> instead chooses the more common round-away-from-zero behavior, here though I
>> am unsure where the dependent implementation would end up existing.

> Oh, so does the rounding code use OS facilities, then, rather than being
> implemented in Postgres? - Didn't know that, though I was aware PG does
> that in other areas (collation, for example).

Yes.

But this here:
http://msdn.microsoft.com/en-us/library/0b34tf65.aspx
claims that Windows C++ is IEEE compliant, so it should behave like Linux.

On systems where the function exists, PostgreSQL uses the rint() function.
On other systems (like Windows), it defines rint() as

double
rint(double x)
{
    return (x >= 0.0) ? floor(x + 0.5) : ceil(x - 0.5);
}

It is interesting that the above function, when applied to 0.5 on my
Linux x86_64 system, yields "1".

So while rint() follows the IEEE standard's default (if a value is exactly
between two integers, round to the even one), PostgreSQL's replacement
function doesn't.

So maybe there is a bug after all, and the replacement function
should be changed.

Yours,
Laurenz Albe

-- 
Sent via pgsql-general mailing list (pgsql-general@xxxxxxxxxxxxxx)
To make changes to your subscription:
http://www.postgresql.org/mailpref/pgsql-general





[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[Index of Archives]     [Postgresql Jobs]     [Postgresql Admin]     [Postgresql Performance]     [Linux Clusters]     [PHP Home]     [PHP on Windows]     [Kernel Newbies]     [PHP Classes]     [PHP Books]     [PHP Databases]     [Postgresql & PHP]     [Yosemite]
  Powered by Linux