Issues

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

Duplicate of ZF-3473

Fixed with r13990

I've noticed when bcmath extension is enabled the problem reoccurs.


$number = Zend_Locale_Format::toNumber(13547.3678,
                                       array('precision' => 2,
                                             'locale' => $locale));

returns 13547.36 with bcmath enabled. Zend Server 5.0, ZF 1.10.2, PHP 5.2.12, Windows 7.