ZF-4408: Precision and number_format seems to be broken
Description
I encountered a bug when trying to use $number = Zend_Locale_Format::toNumber('26.7857142857', array('precision' => 2, 'locale' => 'sv_SE'); Instead of 26,79 it returned 26,78.
I then tried with the examples given in the reference guide and they also returned wrong results.
{quote} $locale = new Zend_Locale('de_AT'); $number = Zend_Locale_Format::getNumber('13.524,678', array('precision' => 1, 'locale' => $locale)); print $number; // will return 13524.7 {quote}
In fact this code will return 13524.6
{quote} $locale = new Zend_Locale('de_AT'); $number = Zend_Locale_Format::getNumber('13.524,678', array('number_format' => '#.00', 'locale' => $locale)); print $number; // will return 13524.67 {quote} This is currently returning a value of 13524.678
Comments
Posted by Thomas Weidner (thomas) on 2008-09-28T23:39:29.000+0000
Duplicate of ZF-3473
Posted by Thomas Weidner (thomas) on 2009-02-05T14:39:33.000+0000
Fixed with r13990
Posted by Michal Lasak (mlasak) on 2010-04-02T07:59:45.000+0000
I've noticed when bcmath extension is enabled the problem reoccurs.
returns 13547.36 with bcmath enabled. Zend Server 5.0, ZF 1.10.2, PHP 5.2.12, Windows 7.