sagar123 has asked for the wisdom of the Perl Monks concerning the following question:
I am facing a silly error. here is a simple script but its not working beyond for (1..42) that is for (1..43) or more.
$a = 22.400; for (1..43) { $a = $a + 0.001; } print "$a\n";
it should give me 22.443, but I am getting 22.4430000000001. It works fine if I use for (1..42) or less than 42 then I get correct value e.g. for (1..42) I get 22.442 So is there limit to run loop? but I never faced such problem before as I run loop many times.
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re: limit of for loop!!
by moritz (Cardinal) on Jan 01, 2012 at 18:55 UTC | |
|
Re: limit of for loop!!
by toolic (Bishop) on Jan 01, 2012 at 19:00 UTC | |
|
Re: limit of for loop!!
by GrandFather (Saint) on Jan 01, 2012 at 21:41 UTC | |
by sagar123 (Novice) on Jan 02, 2012 at 07:31 UTC | |
|
Re: limit of for loop!!
by Anonymous Monk on Jan 01, 2012 at 19:00 UTC | |
| |
|
Re: limit of for loop!!
by flexvault (Monsignor) on Jan 02, 2012 at 17:11 UTC |