Decimal places and huge fractions.

Discussion in 'Perl' started by Eoin Mcloughlin, Feb 11, 2004.

  1. I have a perl script for calculating sequences that use numbers like
    1/5908979186 however, I need to get more accuracy than the usual 15
    decimal places, is this a limitation of 32-bit machines or is it
    possible to use more decimal places?
    Has something already been written to do this? If not, what would one
    have to do enable it?
     
    Eoin Mcloughlin, Feb 11, 2004
    #1
    1. Advertising

  2. Eoin Mcloughlin <> wrote in message
    news:...
    > I have a perl script for calculating sequences that use numbers like
    > 1/5908979186 however, I need to get more accuracy than the usual 15
    > decimal places, is this a limitation of 32-bit machines or is it
    > possible to use more decimal places?
    > Has something already been written to do this? If not, what would one
    > have to do enable it?
    >


    If you need more precision, then 32 or 64 or .... becomes an issue.
    One possible solution is to do the arithmetic in string form which bypasses
    the machine limitation. It requires special functions for doing the string
    arithmetic but
    I have to guess it's been done ... somewhere. (ie once upon a time for a
    class we
    did at least the easier add, subtract, multiply ....maybe divide)
    There is a time cost, of course.

    Regards....
     
    Chris Crandell, Feb 12, 2004
    #2
    1. Advertising

  3. Eoin Mcloughlin

    Jim Gibson Guest

    In article <>, Eoin Mcloughlin
    <> wrote:

    > I have a perl script for calculating sequences that use numbers like
    > 1/5908979186 however, I need to get more accuracy than the usual 15
    > decimal places, is this a limitation of 32-bit machines or is it
    > possible to use more decimal places?
    > Has something already been written to do this? If not, what would one
    > have to do enable it?
    >


    Check out Math::BigInt (I have not used it). Try

    perldoc Math::BigInt

    for info.

    FYI: This newsgroup is defunct. Try comp.lang.perl.misc in the future.
     
    Jim Gibson, Feb 12, 2004
    #3
  4. Eoin Mcloughlin wrote:
    > I have a perl script for calculating sequences that use numbers like
    > 1/5908979186 however, I need to get more accuracy than the usual 15
    > decimal places,


    More accuracy? Are you doing some astronomic calculations or iterative
    metorological forcasts or nuclear physics or something like that?
    Ususally 10 valid digits (as in your example) are more than any measuring
    equipment can possibly provide.

    However, if you really have a need for higher accuracy then you may want to
    invest some time in learning about computer numerics and how those work.
    There is much more to it then just using a module with a higher number of
    digits and if you are not aware of the potential pitfalls then you are
    likely to be bitten sooner or later.

    jue
     
    Jürgen Exner, Feb 12, 2004
    #4
  5. Eoin Mcloughlin

    Joe Smith Guest

    Joe Smith, Feb 12, 2004
    #5
  6. A bunch people wrote:


    >More accuracy? Are you doing some astronomic calculations or iterative
    >metorological forcasts or nuclear physics or something like that?

    Well, not quite but there are sequences with unusual numbers in them...

    >Math::BigInt and Math::BigRat

    Math::BigFloat worked just fine...

    Thanks people... Great help. Everything is fine to 300-odd decimal
    places, which will do for now...
     
    Eoin Mcloughlin, Feb 13, 2004
    #6
    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. Curt_C [MVP]

    Re: beginner: prob with decimal places

    Curt_C [MVP], May 18, 2004, in forum: ASP .Net
    Replies:
    1
    Views:
    339
    Curt_C [MVP]
    May 18, 2004
  2. Curt_C [MVP]

    Re: beginner: prob with decimal places

    Curt_C [MVP], May 18, 2004, in forum: ASP .Net
    Replies:
    2
    Views:
    544
    Curt_C [MVP]
    May 18, 2004
  3. Harry

    Remove Decimal Places

    Harry, Jun 3, 2004, in forum: ASP .Net
    Replies:
    3
    Views:
    8,966
    VB Programmer
    Jun 3, 2004
  4. Astley Le Jasper
    Replies:
    4
    Views:
    435
    Astley Le Jasper
    Nov 10, 2008
  5. Next
    Replies:
    1
    Views:
    869
    Mike Moore [MSFT]
    Aug 28, 2003
Loading...

Share This Page