Because allowing use of NV values re-introduces the very rounding anomalies we're (normally) trying to avoid:
C:\>perl -MMath::Decimal64=":all" -le "$x=Math::Decimal64->new('0.085'
+); $y = Math::Decimal64->new(0.085);$z = NVtoD64(0.085);print $x;prin
+t $y; print $z;"
Outputs:
85e-3
8500000000000001e-17
8500000000000001e-17
$y and $z are assigned from the actual NV value, whereas $x is assigned the specified decimal value.
The trouble with allowing overloading of NVs is that it makes it just too easy for people to inadvertently use a value that they didn't really mean to use - though I guess the same criticism could be levelled at new() because *it* currently allows assignment of NVs.
NVtoD64() ought to be there so that one *can* assign the NV to a Math::Decimal64 object if one wants. It's name pretty much explicitly indicates what it's going to do, thus making it less likely that one will inadvertently assign an unintended value.
Cheers, Rob | [reply] [d/l] |