On Tue, Mar 17, 2009 at 10:42 AM, praba karan <praba...@gmail.com> wrote:
> The Code which laughed at me :
>
> *<?php
> echo (int)((0.1+0.7)*10);
> ?>*
>
> As per the logic  *ANSWER should be "8" but i'm getting only "7"*.. why it
> is so ???
>
> if the code is written as
>
> *echo ((0.1+0.7)*10); *
> //or
> *echo (float) ((0.1+0.7)*10);*
>
> then no issues in getting the answer "8"..
>
In a Python REPL:

>>> 0.7 + 0.1
0.79999999999999993
>>> _ * 10
7.9999999999999991
>>> int(_)
7
>>>

Dunno if that helps you.

Regards,
Roshan
_______________________________________________
To unsubscribe, email ilugc-requ...@ae.iitm.ac.in with
"unsubscribe <password> <address>"
in the subject or body of the message.
http://www.ae.iitm.ac.in/mailman/listinfo/ilugc

Reply via email to