New code is up in the main post. I want to understand what's going on as well.


There's no problem with "use Math::BigInt;". It makes no difference whether that line is present or not.
What does the damage is "use Math::BigInt ':constant';" because that means all integer values are converted to Math::BigInt objects or, as the docs explain it:
Autocreating constants After "use Math::BigInt ':constant'" all the integer decimal, hexadecimal and binary constants in the given scope are converted +to "Math::BigInt". This conversion happens at compile time.
Effectively, the math operations involving integers will be done using integer arithmetic - which is precisely as you have seen.

You can avoid this behaviour by simply not calling "use Math::BigInt ':constant';".
The only thing you then have to worry about is what happens when an integer value that is too big to fit into an IV comes along.
(perl -V:ivsize will tell you how many bytes your IV's can take up. It depends upon how perl was configured when it was being built and won't necessarily be the same on other builds of perl, even if they are the same version. Typically ivsize is either 4 or 8.)
If all of your integer values will fit into an IV, then there's little more to consider - just remove the offending line of code.

Cheers,
Rob

In reply to Re^8: All Calculations Done with One Variable Give Integer Answers by syphilis
in thread All Calculations Done with One Variable Give Integer Answers by HalNineThousand

Title:
Use:  <p> text here (a paragraph) </p>
and:  <code> code here </code>
to format your post, it's "PerlMonks-approved HTML":



  • Posts are HTML formatted. Put <p> </p> tags around your paragraphs. Put <code> </code> tags around your code and data!
  • Titles consisting of a single word are discouraged, and in most cases are disallowed outright.
  • Read Where should I post X? if you're not absolutely sure you're posting in the right place.
  • Please read these before you post! —
  • Posts may use any of the Perl Monks Approved HTML tags:
    a, abbr, b, big, blockquote, br, caption, center, col, colgroup, dd, del, details, div, dl, dt, em, font, h1, h2, h3, h4, h5, h6, hr, i, ins, li, ol, p, pre, readmore, small, span, spoiler, strike, strong, sub, summary, sup, table, tbody, td, tfoot, th, thead, tr, tt, u, ul, wbr
  • You may need to use entities for some characters, as follows. (Exception: Within code tags, you can put the characters literally.)
            For:     Use:
    & &amp;
    < &lt;
    > &gt;
    [ &#91;
    ] &#93;
  • Link using PerlMonks shortcuts! What shortcuts can I use for linking?
  • See Writeup Formatting Tips and other pages linked from there for more info.