mikeraz has asked for the wisdom of the Perl Monks concerning the following question:
mikeraz@hive:~> perl -e 'my $x = (.0425 * 2) + .0025; print $x - (.042 +5 * 2) - .0025, $/;' 2.16840434497101e-18 mikeraz@hive:~>
Silly me would expect something like 0 to be printed. Why the 2.16840434497101e-18? (OK, round it off and you have 0, but ....)
Digging into this I tried something "simplier" and got more confused:
mikeraz@hive:~> perl -e 'print ((.0425*2) + .0025 ) - ((.0425*2) + .00 +25 ); print $/;' 0.0875 mikeraz@hive:~>
Be Appropriate && Follow Your Curiosity
|
---|
Replies are listed 'Best First'. | |
---|---|
Re: expected 0 not result gotten
by toolic (Bishop) on Dec 21, 2011 at 19:34 UTC | |
by mikeraz (Friar) on Dec 21, 2011 at 19:43 UTC | |
Re: expected 0 not result gotten
by quester (Vicar) on Dec 22, 2011 at 06:40 UTC | |
by Anonymous Monk on Dec 27, 2011 at 09:27 UTC | |
by quester (Vicar) on Dec 28, 2011 at 06:40 UTC | |
Re: expected 0 not result gotten
by sundialsvc4 (Abbot) on Dec 22, 2011 at 10:03 UTC | |
by ikegami (Patriarch) on Dec 22, 2011 at 20:38 UTC |
Back to
Seekers of Perl Wisdom