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
Welcome! If you don't have a Git account, you can't do anything here.
You can add a comment by following this link or if you reported this bug, you can edit this bug over here.
(description)
Block user comment
Status: Assign to:
Package:
Bug Type:
Summary:
From: Fox235 at yandex dot ru
New email:
PHP Version: OS:

 

 [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 Apr 16 12:01:23 2021 UTC