Zend Framework

Currency doesn't round correctly

Details

  • Type: Bug Bug
  • Status: Resolved Resolved
  • Priority: Major Major
  • Resolution: Fixed
  • Affects Version/s: 1.7.6
  • Fix Version/s: 1.8.0
  • Component/s: Zend_Currency
  • Labels:
    None

Description

When is use Zend_Currency, the roundings are working incorrectly (imho).

Unable to find source-code formatter for language: php. Available languages are: javascript, sql, xhtml, actionscript, none, html, xml, java
$currency = new Zend_Currency('EUR', 'nl_NL');

echo $currency->toCurrency('5.678', array('presicion' => 2));

I think it should display the number as: 5,68 but it is displayed as 5,67.

When looking in the code, the toCurrency uses the Zend_Locale_Format::toNumber(). Should it be using the toFloat() function instead?

S.

Activity

Hide
Thomas Weidner added a comment - - edited

Use the correct option...

precision instead of presicion

Show
Thomas Weidner added a comment - - edited Use the correct option... precision instead of presicion
Hide
Sven Franke added a comment -

So I made a typo in the example... whoooo.

BUT!.... In my actual code it was/is the correct option (so no typo) thus the problem remains.

Show
Sven Franke added a comment - So I made a typo in the example... whoooo. BUT!.... In my actual code it was/is the correct option (so no typo) thus the problem remains.
Hide
Thomas Weidner added a comment -

Looks for me as a duplication of ZF-3473 and ZF-5908.
Using your example within my testbed I see no failed rounding using your input.

Are you sure that you are using trunk as you stated within the issue creation and not a fixed release ?

Show
Thomas Weidner added a comment - Looks for me as a duplication of ZF-3473 and ZF-5908. Using your example within my testbed I see no failed rounding using your input. Are you sure that you are using trunk as you stated within the issue creation and not a fixed release ?
Hide
Sven Franke added a comment -

Did I state trunk? Hmz, must be sleeping

I was using 1.7.6, but I get the same results in 1.7.7.

This is the code that I use (just for testing!)

$curr = new Zend_Currency('EUR', 'nl_NL');
 $res = $curr->toCurrency(5.3678, array('display' => Zend_Currency::NO_SYMBOL));
 Zend_Debug::dump($res);

Going to test against trunk

Show
Sven Franke added a comment - Did I state trunk? Hmz, must be sleeping I was using 1.7.6, but I get the same results in 1.7.7. This is the code that I use (just for testing!)
$curr = new Zend_Currency('EUR', 'nl_NL');
 $res = $curr->toCurrency(5.3678, array('display' => Zend_Currency::NO_SYMBOL));
 Zend_Debug::dump($res);
Going to test against trunk
Hide
Sven Franke added a comment -

Ok, I see that the code is working on trunk library.

When can we expect 1.7.8?

Sorry for the troubles! (and thanx for the solution).

I'll better my life by searching and filling the fields correctly.

Show
Sven Franke added a comment - Ok, I see that the code is working on trunk library. When can we expect 1.7.8? Sorry for the troubles! (and thanx for the solution). I'll better my life by searching and filling the fields correctly.
Hide
Thomas Weidner added a comment -

Fixed for the next minor release (small BC break environment related)

Show
Thomas Weidner added a comment - Fixed for the next minor release (small BC break environment related)

People

Vote (0)
Watch (0)

Dates

  • Created:
    Updated:
    Resolved: