Issues

ZF-9698: CLONE - Precision and number_format seems to be broken

Issue Type: Bug Created: 2010-04-17T08:56:14.000+0000 Last Updated: 2010-04-22T12:22:53.000+0000 Status: Resolved Fix version(s): - 1.10.4 (28/Apr/10)

Reporter: Michal Lasak (mlasak) Assignee: Thomas Weidner (thomas) Tags: - Zend_Locale

Related issues: - ZF-4408

Attachments: - screenshot-1.jpg

Description

I've noticed when bcmath extension is enabled the problem with broken precision and number_format 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. Correct output should be 13547.37.

Comments

Posted by Thomas Weidner (thomas) on 2010-04-20T13:37:53.000+0000

Closing as not reproduceable

Using the given code with locale 'de' and var_dump of the returned output I get

<pre class="highlight">
string '13.547,37' (length=9)

Using 'fr' I get:

<pre class="highlight">
string '13 547,37' (length=10)

Both results are correct.

Posted by Michal Lasak (mlasak) on 2010-04-21T08:41:55.000+0000

Thomas, have you turned bcmath extension on? This simple script is not working for me with bcmath enabled.

<pre class="highlight">
<?php
require 'Zend/Loader/Autoloader.php';
Zend_Loader_Autoloader::getInstance();
var_dump(extension_loaded('bcmath'));
var_dump(Zend_Locale_Format::toNumber(13547.3678,array('precision' => 2,'locale' => new Zend_Locale('en_US'))));

Outputs:

<pre class="highlight">
bool(true) 
string(9) "13,547.36"

Posted by Michal Lasak (mlasak) on 2010-04-21T08:42:51.000+0000

Please turn on bcmath extension to reproduce problem!

Posted by Thomas Weidner (thomas) on 2010-04-22T11:50:08.000+0000

Using your code I get

<pre class="highlight">
boolean true
string '13,547.37' (length=9)

Note that I am running my tests on Windows where bcmath is enabled per default.

Posted by Michal Lasak (mlasak) on 2010-04-22T12:22:49.000+0000

I've upgraded to ZF 1.10.3 and problem disappears. (but was still present on 1.10.2 :)) Thanks for your willingness anyway.

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