php.net |  support |  documentation |  report a bug |  advanced search |  search howto |  statistics |  random bug |  login
Bug #77483 NumberFormatter::formatCurrency rounding issues with CHF (Swiss Francs)
Submitted: 2019-01-17 22:46 UTC Modified: 2019-01-18 17:16 UTC
From: 1000nettles at gmail dot com Assigned: cmb (profile)
Status: Not a bug Package: Unknown/Other Function
PHP Version: 7.1.26 OS: Amazon Linux / CentOS
Private report: No CVE-ID: None
 [2019-01-17 22:46 UTC] 1000nettles at gmail dot com
Description:
------------
Hi there,

It looks as if a bug that was fixed years ago (https://bugs.php.net/bug.php?id=60083) has reappeared in PHP 7.1.x. While using NumberFormatter::formatCurrency, if you specify CHF (Swiss Francs) as a currency, it will round to the nearest 0.05.

Test script:
---------------
$formatter = new \NumberFormatter('en_US', \NumberFormatter::CURRENCY);
echo $formatter->formatCurrency(12.99, 'CHF');

Expected result:
----------------
CHF12.99

Actual result:
--------------
CHF13.00

Patches

Add a Patch

Pull Requests

Add a Pull Request

History

AllCommentsChangesGit/SVN commitsRelated reports
 [2019-01-18 11:00 UTC] cmb@php.net
-Status: Open +Status: Feedback -Assigned To: +Assigned To: cmb
 [2019-01-18 11:00 UTC] cmb@php.net
It seems to me this never was a PHP issue, but rather an ICU
issue.  Which INTL_ICU_VERSION do you use?
 [2019-01-18 17:04 UTC] 1000nettles at gmail dot com
-Status: Feedback +Status: Closed
 [2019-01-18 17:04 UTC] 1000nettles at gmail dot com
You are absolutely correct - we were using an out-of-date INTL ICU version (50.x). Upgraded to the latest and the rounding disappears. Really appreciate the help, thanks.
 [2019-01-18 17:16 UTC] cmb@php.net
-Status: Closed +Status: Not a bug
 [2019-01-18 17:16 UTC] cmb@php.net
Great that the problem has been resolved.
 
PHP Copyright © 2001-2024 The PHP Group
All rights reserved.
Last updated: Sat Apr 20 10:01:28 2024 UTC