|
php.net | support | documentation | report a bug | advanced search | search howto | statistics | random bug | login |
[2004-05-25 06:20 UTC] andrew dot panin at nvkz dot net
Description:
------------
Just look into the code!
Reproduce code:
---------------
<?php
$in="1234567";
$d = 0;
$d = 3*abs(strlen($in)/3 - floor(strlen($in)/3));
print $d;
//here $d=1, as it PHP print
if ($d == 1) { print "E"; }
//The "E" is NOT prints!
die();
?>
Expected result:
----------------
That the "E" will be shown.
Actual result:
--------------
NOTHING!!!
PatchesPull RequestsHistoryAllCommentsChangesGit/SVN commits
|
|||||||||||||||||||||||||||
Copyright © 2001-2025 The PHP GroupAll rights reserved. |
Last updated: Mon Oct 27 13:00:01 2025 UTC |
This happens on 4.3.7dev too, but... It seems to be a representation problem of 'print $d;'. If you modify your if-clause the following way, it shows what I mean: if ($d > 1) { print "E"; } Now, the 'E' is printed ! It seems, that the value of $d is NOT exactly one : if (((int)$d) == 1) { print "E"; } Whent $d is converted to integer, the 'E' is printed also. Use number_format($d, 20); to see an internal value representation of $d (it reads 1.00000000000000044409). When working with floating point values, never ever test on equality!