Re: Re: Why do these values not match?
| From: | Pierre-Alain Joye | Date: | Tue, 25 Jun 2002 22:30:58 +0000 |
| Subject: | Re: Re: Why do these values not match? | ||
| References: | 1 2 3 | Groups: | php.db |
| Request: | Send a blank email to php-db+get-20111@lists.php.net to get a copy of this message | ||
On Tue, 25 Jun 2002 15:00:08 -0700 (PDT)
Manuel <manuel@ochoa-usa.com> 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<br>");
> print("Production = $production<br>");
>
> if($total != $production) {
> print("Totals do not Match!");
> }
> else {
> print("Totals are in Balance");
> }
You do not have to use == or != with floats numbers, never, whatever langages you use.
If you really want to compare float, use 'bccomp' instead and define the precision as 3rd
parameter.
int bccomp ( string left_operand, string right_operand [, int scale])
hth
pa
ps : on new thread, start a new message, do not use reply, just think about poor men like using tree
view :))