Anonymous Monk has asked for the wisdom of the Perl Monks concerning the following question:
Hi,
I want to create a simple output ranging from 0 to zmax in distinct steps. Those steps shall get larger towards the end. Here's my simple script:
And here's the output at a later stage:my $zmax = 60; # Maximum depth in your model my $dz = 0.05; # Grid spacing in z-direction for (my $i=0; $i <= $zmax; $i = $i+$dz) { print $i."\n"; }
That's not the correct value !! This prevents me from making a direct comparison with an integer number (which I can find ways around), but the result is simply wrong!! What's happening there?3.6 3.65 3.69999999999999 3.74999999999999
|
---|
Replies are listed 'Best First'. | |
---|---|
Re: Wrong calculations in for loop
by toolic (Bishop) on Aug 22, 2012 at 13:02 UTC | |
Re: Wrong calculations in for loop
by MidLifeXis (Monsignor) on Aug 22, 2012 at 13:01 UTC | |
Re: Wrong calculations in for loop
by BrowserUk (Patriarch) on Aug 22, 2012 at 13:50 UTC | |
Re: Wrong calculations in for loop
by moritz (Cardinal) on Aug 22, 2012 at 13:10 UTC | |
by Athanasius (Archbishop) on Aug 22, 2012 at 13:22 UTC | |
by SuicideJunkie (Vicar) on Aug 22, 2012 at 20:31 UTC | |
Re: Wrong calculations in for loop
by Anonymous Monk on Aug 22, 2012 at 13:08 UTC |
Back to
Seekers of Perl Wisdom