Re: Re: Why do these values not match?

From: Date: Tue, 25 Jun 2002 22:38:40 +0000
Subject: Re: Re: Why do these values not match?
References: 1  Groups: php.db 
Request: Send a blank email to php-db+get-20113@lists.php.net to get a copy of this message
Here is a way to work around this, use number_format(). $total= 332.06; $production = 45.11 + 134.38 + 85.35 + 67.22; print("Total = $total"); print("Production = $production"); if(number_format($total) != number_format($production)) { print("Totals do not Match!"); } else { print("Totals are in Balance"); } Tony S. Wu I tried it and the if statement is still treating the evaluation as if they are not equal. I also did this: $test = $total - $production; print "$test"; and got this as the result: -5.68434188608E-014 What is going on here? Seth Yount wrote:try switching your != to an == to see if it works the other way around. That might let you know if is the if statement or something else. gl -- Seth Manuel wrote: > The "if" statement is not working here. Does anybody know why? > > $total= 332.06; > $production = 45.11 + 134.38 + 85.35 + 67.22; > > print("Total = $total "); > print("Production = $production "); > > if($total != $production) { > print("Totals do not Match!"); > } > else { > print("Totals are in Balance"); > } > > > > --------------------------------- > Do You Yahoo!? > Sign-up for Video Highlights of 2002 FIFA World Cup > -- PHP Database Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php ~ Manuel Ochoa ~ Seven days is too long to wait for a gun! --------------------------------- Do You Yahoo!? Sign-up for Video Highlights of 2002 FIFA World Cup

« previous php.db (#20113) next »