php.net |  support |  documentation |  report a bug |  advanced search |  search howto |  statistics |  random bug |  login
Bug #17726 Serious comparision operator bug using floating point vars
Submitted: 2002-06-12 09:53 UTC Modified: 2002-06-12 09:54 UTC
Votes:1
Avg. Score:5.0 ± 0.0
Reproduced:1 of 1 (100.0%)
Same Version:1 (100.0%)
Same OS:1 (100.0%)
From: Snelders at Infocure dot nl Assigned:
Status: Not a bug Package: Unknown/Other Function
PHP Version: 4.2.1 OS: Redhat kernel 2.2.19-7.0.12
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:
10 + 9 = ?
Subscribe to this entry?

 
 [2002-06-12 09:53 UTC] Snelders at Infocure dot nl
--- My code ---
<?
$HRDelta = 1;

function HRValue($Max = 100){
	global $HRDelta;
	$C = ($Max < 0 ? -1 : 1);
	
	$Order = floor(log10($Max * $C));
	$i = 1;
	do{
		$AxisMax = $i * $HRDelta * pow(10,$Order);
		$i++;
	}while($Max * $C >= $AxisMax);
	
	echo "Expression: (\$Max * \$C >= \$AxisMax) ? \"true\" : \"false\")<BR>\n";
	echo "Evaluated: (" . $Max * $C . " >= $AxisMax) ? \"true\" : \"false\")<BR>\n";
	echo "Answer: " . (($Max * $C >= $AxisMax) ? "true" : "false") . "<BR>";
	return $C * $AxisMax;
}

echo HRValue(-0.7);
?>

--- My Output ---
Expression: ($Max * $C >= $AxisMax) ? "true" : "false")
Evaluated: (0.7 >= 0.7) ? "true" : "false")
Answer: false
-0.7
--- Description problem ---
The last comparison operator returns false for some unknown reason. I also checked the variables using var_dump and they seem to be exactly the same (float(0.7)) according to php.

--- My configure line --
'./configure' '--with-apxs=/usr/sbin/apxs' '--with-mysql=/usr/' '--with-png-dir=/usr/local/libpng' '--with-gd=/usr/local/gd-1.8.4' '--with-zlib' '--with-ttf' '--with-freetype-dir=/usr/local/freetype2' '--with-xml' '--with-oracle=/users/home/oskarsson/OraHome1' '--with-oci8=/users/home/oskarsson/OraHome1'



Patches

Add a Patch

Pull Requests

Add a Pull Request

History

AllCommentsChangesGit/SVN commitsRelated reports
 [2002-06-12 09:54 UTC] derick@php.net
Thank you for taking the time to write to us, but this is not
a bug. Please double-check the documentation available at
http://www.php.net/manual/ and the instructions on how to report
a bug at http://bugs.php.net/how-to-report.php

Search the archives... and see: http://www.php.net/manual/en/language.types.float.php
 
PHP Copyright © 2001-2022 The PHP Group
All rights reserved.
Last updated: Thu May 19 06:05:44 2022 UTC