php.net |  support |  documentation |  report a bug |  advanced search |  search howto |  statistics |  random bug |  login
Bug #31018 all
Submitted: 2004-12-08 12:02 UTC Modified: 2004-12-08 12:32 UTC
From: Fox235 at yandex dot ru Assigned:
Status: Not a bug Package: *Programming Data Structures
PHP Version: 4.3.9 OS: Linux
Private report: No CVE-ID: None
 [2004-12-08 12:02 UTC] Fox235 at yandex dot ru
Description:
------------
not 1!But it's must = 1

Reproduce code:
---------------
$a=split(';' , $Ver);
rsort($a);
print_r($a);
$S = array_sum($a);
$f=floatval($S);

if ($f == 1)
{ echo "Yes, it's 1";
}
else 
{ echo "<br>Not, it's not 1";}
 ?>

Expected result:
----------------
Array ( [0] => 0.5 [1] => 0.2 [2] => 0.1 [3] => 0.1 [4] => 0.1 ) 
Yes, it's 1

Actual result:
--------------
Array ( [0] => 0.5 [1] => 0.2 [2] => 0.1 [3] => 0.1 [4] => 0.1 ) 
Not, it's not 1

Patches

Pull Requests

History

AllCommentsChangesGit/SVN commitsRelated reports
 [2004-12-08 12:23 UTC] tony2001@php.net
Thank you for this bug report. To properly diagnose the problem, we
need a short but complete example script to be able to reproduce
this bug ourselves. 

A proper reproducing script starts with <?php and ends with ?>,
is max. 10-20 lines long and does not require any external 
resources such as databases, etc.

If possible, make the script source available online and provide
an URL to it here. Try avoid embedding huge scripts into the report.


 [2004-12-08 12:32 UTC] mgf@php.net
Floating point values have a limited precision. Hence a value might 
not have the same string representation after any processing. That also
includes writing a floating point value in your script and directly 
printing it without any mathematical operations.
 
Thank you for your interest in PHP.


 
PHP Copyright © 2001-2024 The PHP Group
All rights reserved.
Last updated: Mon Dec 30 14:01:28 2024 UTC