Yes, use an integer for the counter, and derive the floating point number from it. Integers are represented accurately and they don't accumulate error (unless they grow beyond a certain size).
my $i=0; print($i, "\n"); while ($i < 10){ my $n = ++$i / 10; print($n, "\n"); }
Update: oops, typo fixed.
In reply to Re^2: non-integer increments
by ikegami
in thread non-integer increments
by spiccioni
| For: | Use: | ||
| & | & | ||
| < | < | ||
| > | > | ||
| [ | [ | ||
| ] | ] |