in reply to Deep recursion on subroutine with bignum and Astro::Units

On a general note, I consider it unwise of the module author to use bignum and doubly-unwise for them to recommend that everyone using their module should do so. Each of bignum, bigint, bigrat can be fine and useful for simple one-liners, but for anything more complex they are very likely to cause problems.

For this specific issue, note that the current Math::BigInt maintainer has made wide-reaching changes multiple times in recent months in an attempt to make the interactions between the different classes behave more sanely in the context of use bignum; it is not clear to me whether it has now reached a stable point. So you may want to try both more recent and older versions of the distribution - check the changelog for references to "upgrading and downgrading".

For getting the calculations you are using to work reliably, I suggest ditching bignum; instead instantiate your numbers as Math::BigFloat, and hope that the use of bignum inside Astro::Units doesn't result in unexpected conversions to Math::BigInt or Math::BigRat.

Note that you should also be able to change the Math::BigFloat configuration after loading Astro::Units, if the latter's choices are not suitable for your needs.

Replies are listed 'Best First'.
Re^2: Deep recursion on subroutine with bignum and Astro::Units
by Anonymous Monk on Jan 21, 2023 at 17:38 UTC
    Thank you Monks! I'm still struggling to isolate the problem to an SSCE but did make an interesting discovery. Turns out the math is not causing the error. I though it was because commenting that line out eliminated it. Just before doing the math I use "int" on one of the numbers. If I don't use "int" the program works! It also works if "int" is used and "use bignum" is commented out AND this is done: Math::BigFloat->config({ div_scale => 1 }); (don't need to use Math::BigFloat, cause I guess Astro::Units already loaded it). I have no idea what is going on but will just not use "int". Hope this makes sense. Thanks again!