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
    for (0..10) { print $n/10,"\n"; }
    ---
    demerphq

Re^3: non-integer increments
by si_lence (Deacon) on Dec 02, 2004 at 16:25 UTC
    just a small remark
    your probably meant
        $n = $i / 10;
    else you print out a few 0s
    si_lence