in reply to Re: Efficiently working with huge exponents
in thread Efficiently working with huge exponents

Yeah, that's the same type of thing that Math::BigApprox makes much easier:

$ time perl -MMath::BigApprox=c -le'print c(2)**1024000' 5.194693e+308254 real 0m0.021s user 0m0.012s sys 0m0.004s

And it makes a good guess at how many decimal places to show as well.

- tye        

Replies are listed 'Best First'.
Re^3: Efficiently working with huge exponents (yeah)
by Laurent_R (Canon) on Mar 20, 2015 at 21:54 UTC
    Thank you, tye ++, I did not know about this module until today, it looks very interesting, I'll look at it and at its code.

    I was only trying to give a very basic proof of concept to try to help the OP. Surely, your module offers much more than my poor basic attempts. Congrats for it.

    Je suis Charlie.

      No, I'm glad you laid out the fairly simple math that lets one do these types of calculations quickly and fairly easily.

      I just saw the opportunity to connect the two suggestions and thus 1) give people a quick intro to what Math::BigApprox is doing under the covers and 2) let the OP know that they don't have to do this by hand if this level of accuracy is acceptable.

      Thanks for showing the math that I didn't have/take the time to. :)

      - tye        

Re^3: Efficiently working with huge exponents (yeah)
by wanna_code_perl (Friar) on Mar 21, 2015 at 13:55 UTC

    Thanks to you both. While I'll probably just use Math::BigApprox for my current need, re-learning a little math never hurt anyone (much).

      ... I'll probably just use Math::BigApprox for my current need ...

      When the original post first appeared, I didn't notice any mention of perfect precision *not* being desired. Was that part of the post always there ?
      Anyway, just to correct my original reply to cater for perfect precision *not* being required:
      perl -MMath::MPFR=:mpfr -le "Rmpfr_set_default_prec(28);print Math::MP +FR->new(2) ** 1024000;" 5.194693363e308254
      (In Math::MPFR, precision is specified in bits.)

      You *can* specify precision for your Math::BigFloat numbers, too - it's in the docs.

      Cheers,
      Rob
        When the original post first appeared, I didn't notice any mention of perfect precision *not* being desired. Was that part of the post always there ?

        Yes it was, and if it wasn't, I'd have clearly annotated the change.

        Thanks for the updated tip!