ZF-7170: Error rounding float value with Zend_Locale_Format::toNumber()


I tried to round 98.99999625 value with Zend_Locale_Format::toNumber() and I get result 98, I expected 99.00.

Here is the code which reproduces this bug:

$result = Zend_Locale_Format::toNumber(98.99999625, array('precision' => 2)); Zend_Debug::dump($result);

Dump result:

string(5) "98.00"


Running your code I receive: string '98,99' (length=5)

Your result is not reproducable for me.

ZF 1.8.4 Thomas?

And set sv_SE locale.

Closing as non-issue.

Use toFloat() when you want to have float values. Set a locale when you want to use a specific locale.

Please read the manual and the API doc for details.