Beefy Boxes and Bandwidth Generously Provided by pair Networks
We don't bite newbies here... much
 
PerlMonks  

comment on

( [id://3333]=superdoc: print w/replies, xml ) Need Help??

Thank you thanos1983 for the obvious time you've spent looking at this. I came to the same conclusion as you (and hence my title) that there is some sort of clash between Math::BigFloat/bignum and Math::FixedPrecision but Math::FixedPrecision is really only a Math::BigFloat wrapper so I don't understand that.

I can only think using bignum causes math inside Math::FixedPrecision (of which there is very little) to use Math::BigFloats and this breaks things or more likely something else (the missing mantissa is very strange). I'd really like to know what is going on and I'll have another go at looking in to it tonight.

Although your alternative appears to work it is not quite what Math::FixedPrecision does. ffround does bankers rounding and Math::FixedPrecision does no rounding. e.g.,

use strict; use warnings; use Math::FixedPrecision; my $x = 3.145; my $y = Math::FixedPrecision->new($x, 2); print "$x, $y\n"; # outputs 3.145, 3.14

If you change your 1.1415 to 1.145 you'll see the difference.

Basically the 2 modules in question were written by 2 different people. One module only needed a dozen or so lines of code using Math::FixedPrecision. The other module was massive and had loads of math so the author chose to simplify it and use bignum. This problem only occurred when someone tried to write a test which used both.

I have some possible solutions not that disimilar to yours but it is nagging at me as why you cannot mix the two and what is going on.

Thanks again for looking at this, it is much appreciated.


In reply to Re^2: Math::FixedPrecision and bignum clash by mje
in thread Math::FixedPrecision and bignum clash by mje

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



  • Are you posting in the right place? Check out Where do I post X? to know for sure.
  • Posts may use any of the Perl Monks Approved HTML tags. Currently these include the following:
    <code> <a> <b> <big> <blockquote> <br /> <dd> <dl> <dt> <em> <font> <h1> <h2> <h3> <h4> <h5> <h6> <hr /> <i> <li> <nbsp> <ol> <p> <small> <strike> <strong> <sub> <sup> <table> <td> <th> <tr> <tt> <u> <ul>
  • Snippets of code should be wrapped in <code> tags not <pre> tags. In fact, <pre> tags should generally be avoided. If they must be used, extreme care should be taken to ensure that their contents do not have long lines (<70 chars), in order to prevent horizontal scrolling (and possible janitor intervention).
  • Want more info? How to link or How to display code and escape characters are good places to start.
Log In?
Username:
Password:

What's my password?
Create A New User
Domain Nodelet?
Chatterbox?
and the web crawler heard nothing...

How do I use this?Last hourOther CB clients
Other Users?
Others browsing the Monastery: (1)
As of 2024-04-25 03:52 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found