Re: sprintf()'s in if()'s
| From: | Jason Brooke | Date: | Sat, 05 May 2001 00:45:32 +0000 |
| Subject: | Re: sprintf()'s in if()'s | ||
| References: | 1 | Groups: | php.general |
| Request: | Send a blank email to php-general+get-51491@lists.php.net to get a copy of this message | ||
> I suppose when you have so few problems you get to nitpick..
>
> Guess my question is; why doesn't this work?
>
> if(sprintf("%01.2f",$Result[CurrentPrice]+$Result[Increment]) <=
sprintf("%01.2f",$BidAmt)) {
>
> when this works;
> if(0.30 <= 1.00) {
>
> I'll just settle with a workaround for now.
>
> Thanks,
> Chris
The former is being treated as a string, the latter is a double/float
You probably don't need to format them when making the comparison. Just try:
if ( ($Result[CurrentPrice]+$Result[Increment]) <= $BidAmt) {
jason