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
View Add Comment Developer Edit
Welcome! If you don't have a Git account, you can't do anything here.
You can add a comment by following this link or if you reported this bug, you can edit this bug over here.
Block user comment
Status: Assign to:
Package:
Bug Type:
Summary:
From: gman at xrbr dot com
New email:
PHP Version: OS:

 

 [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

Add a Patch

Pull Requests

Add a Pull Request

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-2020 The PHP Group
All rights reserved.
Last updated: Thu Nov 26 04:01:23 2020 UTC