Search Postgresql Archives

Re: [GENARAL] round() bug

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

 



On 15/04/2014 17:20, David G Johnston wrote:
> Willy-Bas Loos-3 wrote
>> Hi, I ran into some strange behavior. Seems like a bug to me?
>> 
>> wbloos=# select round(0.5::numeric), round(0.5::double precision); 
>> round | round -------+------- 1 |     0 (1 row)
> 
> Not a bug; and likely to simple to have escaped notice this long so
> the first reaction should be "what am I missing here?"
> 
> [google: round .5 postgresql]
> 
> http://grokbase.com/t/postgresql/pgsql-hackers/03ap11tckn/round-function-wrong/oldest
>
>  Round( numeric ) - 0.5 rounds away from zero Round( float ) -
> platform dependent, IEEE 0.5 rounds toward even
> 
> You can argue the decision but at this point it's not likely to
> change.

Interestingly, I get different results (on both 9.1.4 and 9.3.0) on Windows:

postgres=# select round(0.5::numeric), round(0.5::double precision);
 round | round
-------+-------
     1 |     1
(1 row)


postgres=# select version();
                           version
-------------------------------------------------------------
 PostgreSQL 9.1.4, compiled by Visual C++ build 1500, 64-bit
(1 row)


.... Same on 9.3.0.

Ray.

-- 
Raymond O'Donnell :: Galway :: Ireland
rod@xxxxxx


-- 
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