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
Welcome back! If you're the original bug submitter, here's where you can edit the bug or add additional notes.
If you forgot your password, you can retrieve your password here.
Password:
Status:
Package:
Bug Type:
Summary:
From: Snelders at Infocure dot nl
New email:
PHP Version: OS:

 

 [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

Pull Requests

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-2025 The PHP Group
All rights reserved.
Last updated: Thu Jul 03 15:01:34 2025 UTC