It's cheating because I've already got the answer (in part because you identified the problem) but this had nothing at all to do with the values being generated in the other objects. That I used Math::BigInt in the module (and didn't need it except for in one place) was the problem. So having arrived at the problem, the test case is pretty easy:

#!/usr/bin/perl use Math::BigInt ':constant'; $discount = 15; $price = "109.98"; print $discount * $price; exit();

Results NaN unless the use statement is commented out. Then it results in 1649.7;

I'm guessing the problem is that Math::BigInt is converting all numeric constants to Math::BigInt objects, without checking to see that the numeric constant is an integer or not. Since "109.98" is not an integer, Math::BigInt claims it isn't a number. I'm too ignorant to know whether that is by design or even whether that's really what's happening, but it is my guess.


In reply to Re^4: Getting different results with $var++ and $var += 1 by splicer
in thread Getting different results with $var++ and $var += 1 by splicer

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.