Re: Round with money_format
| From: | Richard Quadling | Date: | Fri, 16 Sep 2011 15:30:57 +0000 |
| Subject: | Re: Round with money_format | ||
| References: | 1 | Groups: | php.general |
| Request: | Send a blank email to php-general+get-314905@lists.php.net to get a copy of this message | ||
On 16 September 2011 15:58, Cyril Lopez <cyril@nethik.fr> wrote:
> Hi,
>
> Can someone help me understand how money_format() rounds numbers ?
>
> <?php
> setlocale(LC_ALL, 'fr_FR.UTF-8');
> $price = 12.665;
> echo money_format('%i',$price);
> // 12.66 EUR, 12.67 EUR expected
>
> $price2 = 12.666;
> echo money_format('%i',$price2);
> // 12.67 EUR, ok
>
> echo round($price,2);
> // 12.67, ok
> echo round($price2,2);
> // 12.67, ok
> ?>
>
> Misconfiguration ? Bug ?
> Thanks !
>
> Cyril
Each locale can define its own rules regarding the number of digits to
show, but I can't see anything that covers the rounding.
OOI.
What do you get for 12.66999?
I'm on windows and there's no money_format function (due to a lack of
strfmon() function),
--
Richard Quadling
Twitter : EE : Zend : PHPDoc
@RQuadling : e-e.com/M_248814.html : bit.ly/9O8vFY : bit.ly/lFnVea