number of maximum decimal places supported with Perl

Discussion in 'Perl Misc' started by Jack, Jul 23, 2008.

  1. Jack

    Jack Guest

    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
     
    Jack, Jul 23, 2008
    #1
    1. Advertising

  2. Jack

    Ben Morrow Guest

    Quoth 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 ?


    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, Jul 23, 2008
    #2
    1. Advertising

  3. Jack

    Jack Guest

    On Jul 22, 4:29 pm, Leon Timmermans <> wrote:
    > On Tue, 22 Jul 2008 16:17:15 -0700, Jack wrote:
    > > 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

    >
    > 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
     
    Jack, Jul 23, 2008
    #3
  4. Ben Morrow wrote:
    > Quoth 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 ?

    >
    > 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
    --
    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
     
    John W. Krahn, Jul 23, 2008
    #4
  5. [A complimentary Cc of this posting was sent to
    Jack
    <>], who wrote in article <>:
    > 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
     
    Ilya Zakharevich, Jul 23, 2008
    #5
  6. Jack

    Guest

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

    >Jack wrote:
    >> On Jul 22, 4:29 pm, Leon Timmermans <> wrote:
    >>> On Tue, 22 Jul 2008 16:17:15 -0700, Jack wrote:
    >>>> 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
    >>> 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 ?
    >>

    >
    >About 308?


    308 digit mantissa. Really?

    sln
     
    , Jul 24, 2008
    #6
  7. Jack

    Guest

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

    > wrote:
    >> On Thu, 24 Jul 2008 20:26:50 +0100, RedGrittyBrick <> wrote:
    >>
    >>> Jack wrote:
    >>>> On Jul 22, 4:29 pm, Leon Timmermans <> wrote:
    >>>>> On Tue, 22 Jul 2008 16:17:15 -0700, Jack wrote:
    >>>>>> 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
    >>>>> 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 ?
    >>>>
    >>> About 308?

    >>
    >> 308 digit mantissa. Really?

    >
    >#!/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
     
    , Jul 24, 2008
    #7
    1. Advertising

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

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. Gizmo
    Replies:
    1
    Views:
    3,627
    Jakob Bieling
    Aug 31, 2003
  2. shez

    number of decimal places

    shez, Jan 20, 2005, in forum: C++
    Replies:
    4
    Views:
    6,794
    saurabh.unercat
    Feb 19, 2011
  3. Gaijinco
    Replies:
    29
    Views:
    2,973
    Anonymous 7843
    Sep 28, 2005
  4. Gaijinco
    Replies:
    27
    Views:
    1,107
    Anonymous 7843
    Sep 28, 2005
  5. harryos
    Replies:
    4
    Views:
    1,701
Loading...

Share This Page