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
View Add Comment Developer Edit
Anyone can comment on a bug. Have a simpler test case? Does it work for you on a different platform? Let us know!
Just going to say 'Me too!'? Don't clutter the database with that please !
Your email address:
MUST BE VALID
Solve the problem:
40 + 8 = ?
Subscribe to this entry?

 
 [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

Add a Patch

Pull Requests

Add a Pull Request

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-2021 The PHP Group
All rights reserved.
Last updated: Fri Mar 05 04:01:23 2021 UTC