php.net |  support |  documentation |  report a bug |  advanced search |  search howto |  statistics |  random bug |  login
Doc Bug #60083 NumberFormatter::formatCurrency wrong for CHF (Swiss Francs)
Submitted: 2011-10-18 10:26 UTC Modified: 2014-07-07 07:03 UTC
From: gman at xrbr dot com Assigned: stas (profile)
Status: Closed Package: intl (PECL)
PHP Version: 5.3.8 OS: SuSE Linux
Private report: No CVE-ID: None
Anyone can comment on a bug. Have a simpler test case? Does it work for you on a different platform? Let us know!
Just going to say 'Me too!'? Don't clutter the database with that please !
Your email address:
MUST BE VALID
Solve the problem:
41 - 29 = ?
Subscribe to this entry?

 
 [2011-10-18 10:26 UTC] gman at xrbr dot com
Description:
------------
I am not from Switzerland, but as far as I know they do have "Rappen", and 1 CHF is equal to 100 Rappen.
So putting float 12.99 to NumberFormatter::formatCurrency should return the said 12,99 ("," is the correct decimal separator for de_DE), but what it does is to output 13,00 which is not correct!

Test script:
---------------
$varNumberFormatter1 = new NumberFormatter("de_DE", NumberFormatter::CURRENCY);
var_dump($varNumberFormatter1->formatCurrency(12.99, "CHF"));

$varNumberFormatter2 = new NumberFormatter("de_DE", NumberFormatter::CURRENCY);
var_dump($varNumberFormatter2->formatCurrency(12.99, "EUR"));

Expected result:
----------------
string(10) "12,99 CHF"
string(10) "12,99 €"


Actual result:
--------------
string(10) "13,00 CHF"
string(10) "12,99 €"


Patches

Pull Requests

History

AllCommentsChangesGit/SVN commitsRelated reports
 [2011-10-18 10:29 UTC] gman at xrbr dot com
-Status: Open +Status: Closed
 [2011-10-18 10:29 UTC] gman at xrbr dot com
They do not have "1 Rappen" coins! That is the reason.
 [2011-10-19 14:25 UTC] johannes@php.net
Re-Opening this as this should be made clear in the documentation. Can be quite unexpected.
 [2011-10-19 14:25 UTC] johannes@php.net
-Status: Closed +Status: Re-Opened -Type: Bug +Type: Documentation Problem
 [2014-07-06 23:17 UTC] php at deep-freeze dot ca
Works as expected with PHP 5.4.21 / ICU 53

$nf = new NumberFormatter("de-DE", NumberFormatter::CURRENCY); 
var_dump($nf->formatCurrency(12.99, "CHF"));

Actual Result:
--------------
string(10) "12,99 CHF"
 [2014-07-07 07:03 UTC] stas@php.net
-Status: Re-Opened +Status: Closed -Assigned To: +Assigned To: stas
 [2014-07-07 07:03 UTC] stas@php.net
Looks like it's working fine with latest PHP and ICU.
 [2014-07-07 07:03 UTC] stas@php.net
Looks like it's working fine with latest PHP and ICU.
 
PHP Copyright © 2001-2024 The PHP Group
All rights reserved.
Last updated: Mon Oct 07 17:01:28 2024 UTC