Re: Bug?
| From: | Bjorn Van Simaeys | Date: | Wed, 08 Aug 2001 16:11:36 +0000 |
| Subject: | Re: Bug? | ||
| References: | 1 | Groups: | php.general |
| Request: | Send a blank email to php-general+get-61851@lists.php.net to get a copy of this message | ||
Hello,
I remember there was a warning in the PHP Manual about
this. This is it:
** Never cast an unknown fraction to integer, as this
can sometimes lead to unexpected results.
** echo (int) ( (0.1+0.7) * 10 ); // echoes 7!
So do your calculations first, and then echo the
results. This way you get good habits in programming.
And your code will be easier to read as well!
Greetz,
Bjorn Van Simaeys
www.bvsenterprises.com
--- "[Intent A/S] Tais M. Hansen" <tmh@intent.dk>
wrote:
> Hi!
>
> I just came across this weird thing. Bug? You tell
> me!
>
> print (int)((8.85-8)*100);
>
> I would think the line above would print "85". But
> for some reason, it
> prints "84"?? Can anyone tell me why that is?
>
> --
> Intent A/S
> Tais M. Hansen
> Web Developer
>
>
>
>
> --
> PHP General Mailing List (http://www.php.net/)
> To unsubscribe, e-mail:
> php-general-unsubscribe@lists.php.net
> For additional commands, e-mail:
> php-general-help@lists.php.net
> To contact the list administrators, e-mail:
> php-list-admin@lists.php.net
>
__________________________________________________
Do You Yahoo!?
Make international calls for as low as $.04/minute with Yahoo! Messenger
http://phonecard.yahoo.com/