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
Welcome back! If you're the original bug submitter, here's where you can edit the bug or add additional notes.
If you forgot your password, you can retrieve your password here.
Password:
Status:
Package:
Bug Type:
Summary:
From: 1000nettles at gmail dot com
New email:
PHP Version: OS:

 

 [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

Pull Requests

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-2025 The PHP Group
All rights reserved.
Last updated: Wed Jul 02 19:01:36 2025 UTC