From:             
Operating system: Windows XP Professional SP3
PHP version:      5.3.5
Package:          Scripting Engine problem
Bug Type:         Bug
Bug description:unexpected results to comparing strings converted to floating

Description:
------------
I have a strings with float numbers, in format integer.decimal (eg 916.32),
and 

using operators (<,>,==,===) don't working as expecting.



Additional info:



System  Windows NT WEBMASTER 5.1 build 2600 (Windows XP Professional Service


Pack 3) i586



Build Date      Jan 5 2011 20:26:24



Compiler        MSVC9 (Visual C++ 2008)



Architecture    x86



Configure Command       cscript /nologo configure.js "--enable-snapshot-build" 

"--disable-isapi" "--enable-debug-pack" "--disable-

isapi"http://bugs.php.net/bugs-generating-backtrace.php "--without-mssql"
"--

without-pdo-mssql" "--without-pi3web" "--with-pdo-oci=D:\php-

sdk\oracle\instantclient10\sdk,shared" "--with-oci8=D:\php-

sdk\oracle\instantclient10\sdk,shared" "--with-oci8-11g=D:\php-

sdk\oracle\instantclient11\sdk,shared" "--enable-object-out-dir=../obj/"
"--

enable-com-dotnet" "--with-mcrypt=static"



precision               14      14

serialize_precision     100     100

PROCESSOR_ARCHITECTURE  x86

PROCESSOR_IDENTIFIER    x86 Family 6 Model 15 Stepping 13, GenuineIntel

PROCESSOR_LEVEL         6

PROCESSOR_REVISION      0f0d



Intel Core 2 Duo CPU E4500 @ 2.2Ghz



Download from: http://windows.php.net/download/



Test script:
---------------
echo "<pre>";

$string1 = "932.16";

$substring1 = "3.16";

$substring2 = "454";

$substring3 = "475";

$number2 = floatval(floatval($substring1) + floatval($substring2) +
floatval($substring3));

$number1 = floatval($string1);

var_dump($number1);//expected: float(932.16), current: float(932.16), OK

var_dump($number2);//expected: float(932.16), current: float(932.16), OK

var_dump($number1 < $number2);//expected: bool(false), current: bool(true),
FAIL

var_dump($number1 > $number2);//expected: bool(false), current:
bool(false), OK

var_dump($number1 == $number2);//expected: bool(true), current:
bool(false), FAIL

var_dump($number1 === $number2);//expected: bool(true), current:
bool(false), FAIL

var_dump(bccomp($number1,$number2));//expected: int(0), current: int(0),
OK

echo "</pre>";

Expected result:
----------------
float(932.16)

float(932.16)

bool(false)

bool(false)

bool(true)

bool(true)

int(0)

Actual result:
--------------
float(932.16)

float(932.16)

bool(true)

bool(false)

bool(false)

bool(false)

int(0)

-- 
Edit bug report at http://bugs.php.net/bug.php?id=54187&edit=1
-- 
Try a snapshot (PHP 5.2):            
http://bugs.php.net/fix.php?id=54187&r=trysnapshot52
Try a snapshot (PHP 5.3):            
http://bugs.php.net/fix.php?id=54187&r=trysnapshot53
Try a snapshot (trunk):              
http://bugs.php.net/fix.php?id=54187&r=trysnapshottrunk
Fixed in SVN:                        
http://bugs.php.net/fix.php?id=54187&r=fixed
Fixed in SVN and need be documented: 
http://bugs.php.net/fix.php?id=54187&r=needdocs
Fixed in release:                    
http://bugs.php.net/fix.php?id=54187&r=alreadyfixed
Need backtrace:                      
http://bugs.php.net/fix.php?id=54187&r=needtrace
Need Reproduce Script:               
http://bugs.php.net/fix.php?id=54187&r=needscript
Try newer version:                   
http://bugs.php.net/fix.php?id=54187&r=oldversion
Not developer issue:                 
http://bugs.php.net/fix.php?id=54187&r=support
Expected behavior:                   
http://bugs.php.net/fix.php?id=54187&r=notwrong
Not enough info:                     
http://bugs.php.net/fix.php?id=54187&r=notenoughinfo
Submitted twice:                     
http://bugs.php.net/fix.php?id=54187&r=submittedtwice
register_globals:                    
http://bugs.php.net/fix.php?id=54187&r=globals
PHP 4 support discontinued:          http://bugs.php.net/fix.php?id=54187&r=php4
Daylight Savings:                    http://bugs.php.net/fix.php?id=54187&r=dst
IIS Stability:                       
http://bugs.php.net/fix.php?id=54187&r=isapi
Install GNU Sed:                     
http://bugs.php.net/fix.php?id=54187&r=gnused
Floating point limitations:          
http://bugs.php.net/fix.php?id=54187&r=float
No Zend Extensions:                  
http://bugs.php.net/fix.php?id=54187&r=nozend
MySQL Configuration Error:           
http://bugs.php.net/fix.php?id=54187&r=mysqlcfg

Reply via email to