[Ilugc] Problem in PHP Type conversion.
Roshan Mathews
rmathews at gmail.com
Tue Mar 17 10:51:38 IST 2009
On Tue, Mar 17, 2009 at 10:42 AM, praba karan <prabampm at 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
More information about the ilugc
mailing list