in reply to Re: (tye)Re: Defining Arrays
in thread Defining Arrays

If you were proposing this as an alternative to doing, for example: for( $i= 1.5; $i < 9.5; $i += 0.1 ) { then, yes, you are correct that errors could start to appear.

But the node that you replied to doesn't suffer from such problems.

As another data point, if you wanted to go from 1.2 to 3.6 in steps of 0.12, you could do this:

for( $i= 120; $i <= 360; $i += 12 ) { push @n, $i/100; }
without risk of errors sneaking in.

The problem results from repeatedly adding something like 0.1 to a number since, in binary floating point, isn't exactly 0.1:

printf "%.30f", 0.1 # prints 0.100000000000000010000000000000

        - tye (but my friends call me "Tye")