Re: PHP can't compare...

From: Date: Mon, 10 Dec 2001 17:51:32 +0000
Subject: Re: PHP can't compare...
References: 1  Groups: php.dev 
Request: Send a blank email to php-dev+get-72980@lists.php.net to get a copy of this message
> But I don't want to do this! I want to compare php numbers, which can be either strings > or floats, > in php! This already works fine when the php number is "passed" as a string, I just > want it to also > work when it's passed as a float/double! Which is not possible. > floor(string(8.2 - 0.2)) == 8.) Sure, this will work for exactly the same reason that floor(round(8.2 - 0.2) == 8.0) will work. What you are implying is that we should always be doing an implicit round() which is not a good idea. This should be something that is up to the developer. > So why doesn't php do this cast/round for me? That's my question. Because that would impose rounding errors and remove the develpor's flexibility for controlling this exactly. -Rasmus

« previous php.dev (#72980) next »