in reply to Pragma clash across modules: bignum and Math::BigFloat
What's going on here is that bignum is meddling with the globals $Math::BigFloat::downgrade and $Math::BigInt::upgrade. It sets downgrade to Math::BigInt, which causes the BigFloat constructor to return BigInts instead, when they don't have a decimal point. Setting $Math::BigInt::upgrade makes BigInt::bsqrt() convert to BigFloat before taking the square root; the problem is, now BigFloat::bsqrt() is working on a copy and doesn't modify the original.
output:use bignum; my $f = Math::BigFloat->new('2'); print $f, "\n"; print ref($f), "\n"; print $f->bsqrt(), "\n"; print $f, "\n";
2 Math::BigInt 1.41421356237309504880168872420969807857 2
There's really no way for bignum to do the right thing. It would have to muck around with those globals every time the flow of control entered or left its lexical scope. And the automatic upgrade feature was just a bad idea from the start. Solution: Don't use bignum, I'm afraid.
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re^2: Pragma clash across modules: bignum and Math::BigFloat (hinthash)
by LanX (Saint) on Dec 07, 2016 at 22:10 UTC | |
by Anonymous Monk on Dec 07, 2016 at 22:36 UTC | |
by LanX (Saint) on Dec 07, 2016 at 23:06 UTC | |
by Anonymous Monk on Dec 08, 2016 at 00:23 UTC | |
by LanX (Saint) on Dec 08, 2016 at 00:39 UTC | |
|