Issues

ZF-4408: Precision and number_format seems to be broken

Issue Type: Bug Created: 2008-09-28T14:49:21.000+0000 Last Updated: 2010-04-17T09:02:04.000+0000 Status: Resolved Fix version(s): - 1.8.0 (30/Apr/09)

Reporter: Peter Myllykoski (kvarnfors) Assignee: Thomas Weidner (thomas) Tags: - Zend_Locale

Related issues: - ZF-3473

Attachments:

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.

<pre class="highlight">
$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.

Have you found an issue?

See the Overview section for more details.

Copyright

© 2006-2016 by Zend, a Rogue Wave Company. Made with by awesome contributors.

This website is built using zend-expressive and it runs on PHP 7.

Contacts