On Sun, 4 May 2008, Jonathan Bond-Caron wrote:

> Thanks, I made some tests after looking at 
> http://lxr.php.net/source/php-src/main/spprintf.c#712
> 
> At first glance, I am utterly confused,
> 
> ini_set('precision', 100);
> setlocale(LC_ALL, 'fr_FR.UTF-8');
> echo 0.3;                             // 
> 0,299999999999999988897769753748434595763683319091796875
> echo "\n";
> echo (string)0.3;             // 0.3
>                                       // expected: 0,3
> echo "\n";
> echo (float)(string)0.3;      // 
> 0,299999999999999988897769753748434595763683319091796875
>                                       // expected: 0,3

Expected should be "0" here actually:

(string) 0.3 -> converts to 
"0,299999999999999988897769753748434595763683319091796875".
(float) "0,299999999999999988897769753748434595763683319091796875" -> converts 
to 0.

I get the following output with both PHP 5.2.6:

0,299999999999999988897769753748434595763683319091796875
0,299999999999999988897769753748434595763683319091796875
0
0,3

Which is what I would expect.

regards,
Derick

-- 
Derick Rethans
http://derickrethans.nl | http://ezcomponents.org | http://xdebug.org

-- 
PHP Internals - PHP Runtime Development Mailing List
To unsubscribe, visit: http://www.php.net/unsub.php

Reply via email to