From:             
Operating system: linux mandriva 2011
PHP version:      Irrelevant
Package:          Scripting Engine problem
Bug Type:         Bug
Bug description:float gives strange result when division is done prior.

Description:
------------
float gives strange result when division is done prior.

Test script:
---------------
$tempout = 5037;
$tempin = 5000;
$tempdiff = $tempout - $tempin;

$tempout = ($tempout / 100);
$tempin = ($tempin / 100);
$tempdiff = ($tempdiff / 100);

$tempdiffActual = $tempout - $tempin;   

var_dump($tempdiffActual);
echo "gives: float(0.37) <br>";

var_dump($tempdiff);
echo "gives: float(0.37) <br>";
        
$something =    $tempdiffActual - $tempdiff;

var_dump($something);
echo "gives: float(-2.5535129566379E-15). Should be 0 <br>";


Expected result:
----------------
var_dump($something);

should be float(0)


Actual result:
--------------
var_dump($something);

result: float(-2.5535129566379E-15)

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

Reply via email to