Hello chiel,
You should definitely read the pages LanX linked to. The second especially is required reading for anyone who wants to write a computer program.
However, I did want to point out you can use the bignum pragma to get Perl 5 to do what you want:
$ perl -e ' use warnings; use bignum; my $size = 0.01; my $step_size = 0.01; while($size < 5){ $size = $size + $step_size; print $size."\n"; } print "FINAL: ".$size."\n";' ... 4.94 4.95 4.96 4.97 4.98 4.99 5 FINAL: 5
Best,
Jim
In reply to Re: While loop with addition goes weird
by jimpudar
in thread While loop with addition goes weird
by chiel
| For: | Use: | ||
| & | & | ||
| < | < | ||
| > | > | ||
| [ | [ | ||
| ] | ] |