Hi,

this problem made me so curious that I investigated a little bit more. I'm pretty sure I found a reason for the problem but not the details.

Look at these two snippets which rebuild IMHO the code path which is taken by the initial code examples:

#!/usr/bin/perl use strict; use warnings; use 5.010; use Data::Dumper; use Math::BigFloat; use bignum; { no bignum; require Math::BigFloat; my $one = Math::BigFloat->new('2'); print Dumper($one); print Dumper("$one"); }

What you get is:

$VAR1 = bless( { 'value' => [ 2 ], 'sign' => '+' }, 'Math::BigInt' ); $VAR1 = '2';

Compare this to the output of the snippet:

#!/usr/bin/perl use strict; use warnings; use 5.010; use Data::Dumper; use Math::BigFloat; #use bignum; { # no bignum; require Math::BigFloat; my $one = Math::BigFloat->new('2'); print Dumper($one); print Dumper("$one"); }

which has the following output:

$VAR1 = bless( { '_m' => [ 2 ], '_es' => '+', '_e' => [ 0 ], 'sign' => '+' }, 'Math::BigFloat' ); $VAR1 = '2';

Do you see the relevant difference? In the first case you get a Math::BigInt object, in the second case a Math::BigFloat object.

After that I'm pretty sure that the constructor of Math::BigFloat does have a problem together with the pragma bignum.

Probably it's worth to file a bug against Math::BigFloat or bignum (probably not so transparent as stated). I really don't know.

Back to the initial problem. Math::FixedPrecision inherits from Math::BigFloat and not from Math::BigInt. Besides the fact that Math::FixedPrecision uses old and depreciated features of Math::BigFloat and manipulates the internals of Math::BigFloat circumventing the API which is a total OO-mess, this intransparency is pretty sure the cause of the exception.

Regards
McA


In reply to Re^2: Math::FixedPrecision and bignum clash by McA
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":



  • 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.