number of maximum decimal places supported with Perl

J

Jack

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
 
B

Ben Morrow

Quoth Jack said:
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 ?

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
 
J

Jack

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

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
 
J

John W. Krahn

Ben said:
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.

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
 
I

Ilya Zakharevich

[A complimentary Cc of this posting was sent to
Jack
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 ?

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! ;-)

Wikipedia is your friend,
Ilya
 
S

sln

#!/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

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
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
473,744
Messages
2,569,483
Members
44,903
Latest member
orderPeak8CBDGummies

Latest Threads

Top