Perl: the Markov chain saw | |
PerlMonks |
Re^8: Math::BigFloat to native double?by syphilis (Archbishop) |
on Jul 13, 2015 at 10:07 UTC ( [id://1134474]=note: print w/replies, xml ) | Need Help?? |
I'll follow up as soon as I've double-checked Ok ... I thought my perl script was printing out the decimal values to full precision, but it wasn't. Corrected decimal representations are: They still don't add up to something near the original input value - but nor should they. Whilst it's quite valid to simply add (concatenate) base 2 or base 16 values, if we want to add in base 10, we need to first convert those hex values to *106* bit precision decimal values. Expressed as decimals to 106 bits of precision, I get: The sum of which is: 3.14159265358979323846264338327953 (This is the same as the input value, except for the extra "3" digit at the end.) I was curious to see the actual hex values that Buk's script was producing so, on perl 5.22.0 (which provides "%a" formatting), I ran: which outputs (when run with the "-l" switch): So the most significant double agrees with my ppc box, but the value of the least significant double differs. Not so sure that splitting the values on the basis of the Math::BigFloat values can provide correct 106-bit values. Cheers, Rob
In Section
Seekers of Perl Wisdom
|
|