in reply to Re: non-integer increments
in thread non-integer increments
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.
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re^3: non-integer increments
by demerphq (Chancellor) on Dec 02, 2004 at 16:35 UTC | |
|
Re^3: non-integer increments
by si_lence (Deacon) on Dec 02, 2004 at 16:25 UTC |