# number of maximum decimal places supported with Perl

#### Do you have a question? Post it now! No Registration Necessary.  Now with pictures!

•  Subject
• Author
• Posted on
Hi there, does anyone know what data type has the most digits of
precision perl, and what the upper bound (maximum) number of decimal
places is for that data type ?

Thank you,

Jack

## Re: number of maximum decimal places supported with Perl

On Tue, 22 Jul 2008 16:17:15 -0700, Jack wrote:

I don't think there is a clearly defined maximum, but if you need to rely
on it Math::BigFloat supports arbitrary precision floating point math.

Leon Timmermans

## Re: number of maximum decimal places supported with Perl

Great, and thank you, do you happen to know is the maximum number of
digits supported on the left hand (positive) side of the decimal ?

Thank you,

Jack

Jack wrote:

--
RGB

## Re: number of maximum decimal places supported with Perl

On Thu, 24 Jul 2008 20:26:50 +0100, RedGrittyBrick

308 digit mantissa. Really?

sln

## Re: number of maximum decimal places supported with Perl

sln@netherlands.com wrote:

#!/usr/bin/perl
use strict;
use warnings;
use Math::BigFloat;

my \$pi = Math::BigFloat->bpi(308);
print "pi is \$pi\n\n";

my \$m = Math::BigFloat->new(1E308);
\$pi->bmul(\$m);
print "pi is \$pi\n\n";

C:\Users\Ian\Documents>perl big.pl
pi is
3.141592653589793238462643383279502884197169399375105820974944592307816406286208
99862803482534211706798214808651328230664709384460955058223172535940812848111745
02841027019385211055596446229489549303819644288109756659334461284756482337867831
652712019091456485669234603486104543266482133936072602491412737245870

pi is
31415926535897932384626433832795028841971693993751058209749445923078164062862089
98628034825342117067982148086513282306647093844609550582231725359408128481117450
28410270193852110555964462294895493038196442881097566593344612847564823378678316
527120190914564856692346034861045432664821339360726024914127372458700

--
RGB

## Re: number of maximum decimal places supported with Perl

On Thu, 24 Jul 2008 21:31:30 +0100, RedGrittyBrick

This is a moving calculation, converted to a string.
I'm thinking of something else, like the largest possible decimal that can be
calculated in the fp machine register.

You got shit fo brains my friend.

sln

## Re: number of maximum decimal places supported with Perl

--
email: perl -le "print scalar reverse qq/moc.noitatibaher0cmdat/"

## Re: number of maximum decimal places supported with Perl

sln@netherlands.com wrote:

Not really. Bigger. Much much bigger.

--
RGB

## Re: number of maximum decimal places supported with Perl

You can finfd out which C type your perl uses for floating-point numbers
with

perl -V:nvtype

You will need to consult the documentation for the C compiler used to
build that perl to find out what precision that implies; in the common
case that your perl is using a 53-bit IEEE 'double' type, you have
approximately 15 digits or precision.

Ben

--
#!/bin/sh
quine="echo 'eval \$quine' >> \\$0; echo quined"
eval \$quine
#                                                        [ben@morrow.me.uk]

## Re: number of maximum decimal places supported with Perl

Ben Morrow wrote:

Or let POSIX help:

\$ perl -V:nvtype
nvtype='double';
\$ perl -MPOSIX -le'print for DBL_DIG, DBL_EPSILON, DBL_MANT_DIG,
DBL_MAX, DBL_MAX_10_EXP, DBL_MAX_EXP, DBL_MIN, DBL_MIN_10_EXP, DBL_MIN_EXP'
15
2.22044604925031e-16
53
1.79769313486232e+308
308
1024
2.2250738585072e-308
-307
-1021

John
--
Perl isn't a toolbox, but a small machine shop where you
can special-order certain sorts of tools at low cost and
in short order.                            -- Larry Wall

## Re: number of maximum decimal places supported with Perl

[A complimentary Cc of this posting was sent to
Jack

Perl can be convinced to use any numeric type supported by a C
compiler.  Practically, I expect that nowadays only IEEE floats are
supported by C compilers; this gives 3 possible flavors: 64bit, 80bit,
and 128bit.  (Please prove me wrong! ;-)