round() problem
Krzysztof Nakielski
nakiel at nakiel.net
Wed Apr 12 10:09:28 UTC 2006
Hi,
I am having problem with round() function in php, python, mysql. I am
not sure if thats FreeBSD issue. I receive the same results on 4.11, 5.4
and 6.0.
php (4.4.1, 5.1.2):
%php -r 'print round(8.075, 2) ."\n";'
8.07
%php -r 'print round(8.085, 2) ."\n";'
8.09
%php -r 'print round(0.075, 2) ."\n";'
0.08
Python (2.4.2):
>>> print "%.2f" % round(8.075, 2)
8.07
>>> print "%.2f" % round(8.085, 2)
8.09
>>> print "%.2f" % round(1.075, 2)
1.08
mysql (4.1.18):
+-----------------+
| round(8.075, 2) |
+-----------------+
| 8.07 |
+-----------------+
+-----------------+
| round(8.085, 2) |
+-----------------+
| 8.09 |
+-----------------+
+-----------------+
| round(6.075, 2) |
+-----------------+
| 6.08 |
+-----------------+
In PostgreSQL everything seems to be ok.
Is this function wrong implemented in php, python, mysql?
Thanks,
--
* Krzysztof Nakielski *
* System Administrator *
More information about the freebsd-questions
mailing list