On Tue, Oct 7, 2008 at 2:45 PM, <[EMAIL PROTECTED]> wrote:

> Hi All, i found this as a Bug in Perl
>
> consider....
>    for($i=0;$i<0.4;$i=$i+0.1)
>     {
>        print "$i\n";
>    }
>
>
> here you wiil get output as expected...
>      0  to 0.3
> it work fine till test is $i<0.7...UPTO HERE EVERYTHING IS GOING
> RIGHT
> BUT magic starts here
>
>
>  for($i=0;$i<0.8;$i=$i+0.1)
>     {
>        print "$i\n";
>    }
>
>
> when i take test as $i<0.8
> output is strange...
> it is
>     0 to 0.8 isted of     0 to 0.7
> same for $i<0.9...
> thus 0.8 onwords ...less than not working as expectation.....
>
>
> it is working as <=
>
>
> isn't it a Joke
>
>
>
> --
> To unsubscribe, e-mail: [EMAIL PROTECTED]
> For additional commands, e-mail: [EMAIL PROTECTED]
> http://learn.perl.org/
>
>
>

Is that a bug in Perl really? Or is it just that floating point operations
are never exact and this deviation is not a strange one as far as processors
go. Try writting the same loop in C or C++ and try again, do the same in
assambler and see what happens.
If Perl is the only one of these languages that has this problem you are
absolutely right, if not your processor is well a processor and floating
point operations are not exact.

I am will put my money on your processor being the issue and Perl working
correct... but I would love to be proven wrong.

Reply via email to