in reply to Re: Math::FixedPrecision and bignum clash
in thread Math::FixedPrecision and bignum clash

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