Using a multiplication to calculate the current value from the beginning every time would probably improve the situation, though not solve it completely as 0.1 can not be represented as a floating point value.
for(my $i = 0; ; $i++) { my $v = $begin + $step * $i; last if $v > $end; print "$v\n"; }
In reply to Re: Weird precision issues in float addition
by salva
in thread Weird precision issues in float addition
by indigoviolet
| For: | Use: | ||
| & | & | ||
| < | < | ||
| > | > | ||
| [ | [ | ||
| ] | ] |