in reply to Re: 4253.95 + 0.9 = 4254.84999999999 (need help to interpret internals)
in thread 4253.95 + 0.9 = 4254.84999999999 (need help to interpret internals)
Your diagnostics are still not telling you the whole of the story, because Devel::Peek is performing the same sort of rounding on the NV value it shows you that perl normally does.
If you want to look at these values in more detail, best to ask for it explicitly with sprintf:
my $a = 4253.95; my $b = 0.9; my $c = $a + $b; print "$a + $b = $c\n"; printf "%.30f + %.30f = %.30f\n", $a, $b, $c;
If you use this with your real code, it is more likely to show you the actual difference between the numbers you get when you enter them explicitly as above and those derived in your code. My guess would be accumulated rounding errors; another possibility would be something modifying $# (see perlvar), but trying to create a testcase to illustrate that I can't get it to do anything at all.
Hugo
|
|---|