RE: [PHP-DEV] Float comparison

From: Date: Sun, 04 May 2008 20:07:01 +0000
Subject: RE: [PHP-DEV] Float comparison
References: 1 2 3  Groups: php.internals 
Request: Send a blank email to internals+get-37442@lists.php.net to get a copy of this message
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 echo "\n"; echo sprintf('%G', 0.3); // 0,3 // expected: 0,3 echo "\n"; I'll dig more into the code... just thought I would share this (PHP 5.2.3) -----Original Message----- From: Stefan Walk [mailto:stefan.walk@gmail.com] Sent: May 4, 2008 1:31 PM To: Jonathan Bond-Caron Cc: internals@lists.php.net Subject: Re: [PHP-DEV] Float comparison > If someone could point me to the float->string code, I'd really appreciate http://lxr.php.net/source/ZendEngine2/zend_operators.c#1075 Regards, Stefan

« previous php.internals (#37442) next »