Subject: | Cross-platform interoperability with BASE_LEN |
Date: | Tue, 14 Oct 2014 13:25:20 -0400 |
To: | <bug-Math-BigInt [...] rt.cpan.org> |
From: | "Todd Davenport" <tdavenport [...] 4-catalyst.com> |
It looks like the BASE_LEN const can never be overridden manually. Its
calc'd during instantiation but there's no way for me to, say, do a
$MBI->_base_len = 8 and override the value.
The reason I need to do this is if you have perl code using 32-bit perl,
building BigFloat objects with $BASE_LEN of 7 and saving them using Dumper
or Storable. If you then load those in on a 64-bit more modern perl
version, with a BASE_LEN of 9, and so the loaded values are all wrong.
So for example, on a 64-bit Strawberry Perl on Windows (This is perl 5,
version 18, subversion 2 (v5.18.2) built for MSWin32-x64-multi-thread):
use Math::BigFloat;
my $MBI = 'Math::BigInt::Calc';
my $num = bless( {"_m" => [4995822,1],"_es" => "-","_p" => -3,"_e" =>
[3],"sign" => "+"}, 'Math::BigFloat' );
print "baselen is ".$MBI->_base_len."\n";
print "num is ".$num->bstr."\n";
gives the following output:
baselen is 9
num is 1004995.822
On a 32-bit ActivePerl on Windows (This is perl, v5.8.8 built for
MSWin32-x86-multi-thread) :
The output for the same code is:
baselen is 7
num is 14995.822
If at a minimum you could manually set base_len in BigInt::Calc, we could
then also set it in BigFloat, have it pass through to its helper object, and
this would solve the problem. Even better would be for _base_len to be part
of the BigFloat object, have it get saved as part of the bless from Dumper,
then when its instantiated back in it passes it back to the MBI helper.
Thanks for your time.