I understood that round() is using the so called Bankers' round algorithm.
But I notice it's inconsistent. The banker's algorithm is magically
activated only for numbers beyond 2047.0. Before 2047, the "classic"
5-is-rounded-up method is used.

5 is rounded up for:

round(9.005, 2) gives 9.01
round(9.015, 2) gives 9.02
round(9.025, 2) gives 9.03
round(9.035, 2) gives 9.04
round(2047.005, 2) gives 2047.01
round(2047.015, 2) gives 2047.02
round(2047.025, 2) gives 2047.03
round(2047.035, 2) gives 2047.04

bankers' rounding:

round(2048.005, 2) gives 2048.01
round(2048.015, 2) gives 2048.01
round(30000.005, 2) gives 30000.01
round(30000.015, 2) gives 30000.01

This can't be intentional, can it? Someone tell me if this is a bug or a
feature please.

Ron

-- 
PHP Internals - PHP Runtime Development Mailing List
To unsubscribe, visit: http://www.php.net/unsub.php

Reply via email to