in reply to Parallelization of multiple nested loops
For instance, on my computer:
for ($i = 0; $i < 1; $i += 0.2) {}; say $i; #==> 1.0 for ($i = 0; $i < 2; $i += 0.2) {}; say $i; #==> 2.2
So, the first loops works right, but the second one runs an extra iteration unexpectedly!
The right approach in this cases is to use an intermediate integer variable:
for ($ix = 0; $ix < 10; $ix++) { my $i = $ix * 0.2; ... }
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re^2: Parallelization of multiple nested loops
by roboticus (Chancellor) on Feb 07, 2018 at 16:33 UTC |