in reply to Wrong calculations in for loop
Luckily you can run the script with only very small changes under Perl 6, and it produces the output you expect:
use v6; my $zmax = 60; # Maximum depth in your model my $dz = 0.05; # Grid spacing in z-direction loop (my $i=0; $i <= $zmax; $i = $i+$dz) { say $i; }
produces
... 3.6 3.65 3.7 3.75 ... 59.9 59.95 60
It accomplishes that magic by doing math with rationals (stored as integer numerator and denominator) by default.
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re^2: Wrong calculations in for loop
by Athanasius (Archbishop) on Aug 22, 2012 at 13:22 UTC | |
by SuicideJunkie (Vicar) on Aug 22, 2012 at 20:31 UTC |