in reply to Determining when Math::BigFloat is necessary?

\I'm not exactly sure how useful the code is, but the reference in the pod should be.

#! perl -slw =pod Extract from [perlnumber] On typical hardware, floating point values can store numbers with up to 53 binary digits, and with binary exponents between -1024 and 1024. In decimal representation this is close to 16 decimal digits and decimal exponents in the range of -304..304. The upshot of all this is that Perl cannot store a number like 12345678901234567 as a floating point number on such architectures without loss of information. =cut use strict; use Math::BigFloat; my $num = '1234567890123456789'; my $bf = Math::BigFloat->new(); for my $digits (14.. 17) { my $strnum = substr( $num, 0, $digits); $bf = Math::BigFloat->new( $strnum ); my $double = 0+$strnum; print $bf, $bf - $double ? 'Use BigFloat': 'Use native'; } __END__ 12345678901234.Use native 123456789012345.Use native 1234567890123456.Use BigFloat 12345678901234567.Use BigFloat

Examine what is said, not who speaks.

The 7th Rule of perl club is -- pearl clubs are easily damaged. Use a diamond club instead.