|
Prev: mismatch between Perl 5.6 and Perl 5.8 in printing high precision values.
Next: IT manager 蛇頭鼠眼edmund yau
From: Mirco Wahab on 2 Apr 2008 07:18 vivekanand.naik(a)gmail.com wrote: > printf("%.32g\n",0.99999999976716936); > > Perl 5.6.1 output: > 0.99999999976716936 --> GOOD > > Perl 5.8.6 output: > 0.99999999976716925 --> ERROR > Any reason for such mismatch ? > Please let me know how to avoid that or any alternative approach if > any. This is in the interval from 1e-16 to 1e-15, which is the accuracy of a IEEE 8 byte double in this number range (52 bits for fraction). Seems to be ok ==> 1 / (2^52). The correct result (above) needs (imho) longer than 8 byte doubles, like perl -MMath::BigFloat -e'print Math::BigFloat->new("0.99999999976716936")->bstr()' Regards M. |