Commit c28ec89b authored by gregor herrmann's avatar gregor herrmann

[svn-upgrade] new version libmath-bigint-perl (1.98)

parent d087a23e
......@@ -4,7 +4,7 @@ Known bugs:
* TODO BUGS:
+ implement test for the upgrading bug in bsub()
* NaN handling in comparisations slightly broken. See also [perl #33106].
* NaN handling in comparisons slightly broken. See also [perl #33106].
* General:
+ BigInt can not the IEEE '-0'. Currently there are no plans to add this. If
......@@ -13,7 +13,7 @@ Known bugs:
* BigFloat:
+ comparing (<=> or == or !=) a BigFloat to a BigInt don't work yet
+ new is first running the entire number trough _split, then again the parts
to construct BigInts. Could be a bit more optimzed.
to construct BigInts. Could be a bit more optimized.
+ fdiv() using F (fallback) mode does not work properly in all cases of
local (aka $x's or $y's) A or P settings. Not definite test case yet, but
it might calculate not enough digits to satisfy the rounding needs.
......
This diff is collapsed.
......@@ -46,7 +46,7 @@ v1.82:
+ Math::BigInt->new(10) / Math::BigFloat->new(2) returned NaN (ditto for
other subclasses of Math::BigInt)
+ $a = new Math::BigInt; creates now a +0, while "" still gives a NaN
This supresses all warnings on undef arguments. Wether this is better...
This suppresses all warnings on undef arguments. Wether this is better...
+ import() would always use "Math::BigInt" and clash with Exporter
+ use Math::BigInt qw(bneg); $a = bneg('1234'); etc did not work at all
+ $x->xxx() now modifies $x in all cases of modifiers and actually returns
......
......@@ -78,6 +78,7 @@ t/sub_mif.t
t/trap.t
t/upgrade.inc
t/upgrade.t
t/upgrade2.t
t/upgradef.t
t/use.t
t/use_lib1.t
......
......@@ -21,7 +21,7 @@ no_index:
- inc
- t
recommends:
Math::BigInt::FastCalc: 0.19
Math::BigInt::FastCalc: 0.24
Math::BigInt::GMP: 1.24
Math::BigInt::Pari: 1.13
Math::BigRat: 0.22
......@@ -30,4 +30,4 @@ requires:
perl: 5.006002
resources:
license: http://dev.perl.org/licenses/
version: 1.96
version: 1.98
......@@ -18,7 +18,7 @@ requires 'perl' => 5.006002;
# upgrading them would make little fluffy kittens much happier:
my @checks;
check_minimum_version ('Math::BigInt::FastCalc' => 0.19);
check_minimum_version ('Math::BigInt::FastCalc' => 0.24);
check_minimum_version ('Math::BigInt::GMP' => 1.24);
check_minimum_version ('Math::BigInt::Pari' => 1.13);
check_minimum_version ('Math::BigRat' => 0.22);
......
......@@ -15,22 +15,22 @@ not run its Makefile.PL or Build.PL.
Hash: SHA1
SHA1 f6ef98e8f3f6a4f670d569f279ef5a3c05c16d0c BENCHMARK
SHA1 2c6c3022349b6328c19aef613607c070900f06ec BUGS
SHA1 0485536221fd19cf892cbfa5d0613eab23be9e57 CHANGES
SHA1 89a3a97b2a4c5bb8919e51856a35b493cd5f9312 BUGS
SHA1 4b60ae58a8988bd06c38a36af87ab4aae5d9edee CHANGES
SHA1 f27c8bd98e754f96c9825fa6ce9f1244c93bdbe6 CREDITS
SHA1 bc2db74538d3acd53f71b5512a144fe18c253ecd GOALS
SHA1 c526ad20dce6fa315a49dfc41b4d27c40f2b6576 HISTORY
SHA1 fe61299e80a1dca48fbaa33f0869e3238ec07c70 HISTORY
SHA1 c42565ad26cdf91502bacf19a4f7080e63c51fe2 INSTALL
SHA1 d6a6c30ee6d9ba6b9afab8bbf6a25e1b23c744e0 LICENSE
SHA1 026e832dbd861b316a4f914359cf5c13eed1cbc3 MANIFEST
SHA1 edf65da7a9aa11174d4367c1db4e11d225e134b0 MANIFEST
SHA1 28e0843acbc175242b0744c7a2a5b2e9397489ee MANIFEST.SKIP
SHA1 a624598995cf51ad8369850ec160cd386f488bdd META.yml
SHA1 b6542d9e43893cc2ffa79fe8884e5e5c1281699e Makefile.PL
SHA1 fbbe0ba6331e008cc7dd321a670fbc3450b01ecc META.yml
SHA1 deef6557db1863323fe676630c906dc071afd0fc Makefile.PL
SHA1 2ec9bfda86bb2073e9423e6a86bb6956c06ebb2f NEW
SHA1 481f5827752d2100914db1eaeb60bf0bbd13529e README
SHA1 6ae43bba2ee4f469ae9f43a916955caff273d41b TODO
SHA1 f1500916b488220b707bc10a0388d7dbcfd52e99 TODO
SHA1 c2bbe82659480de8710b9e64a62d47b64dddd2d2 examples/1000.txt
SHA1 b88700764a8b78c904ed38e50db0286b76228132 examples/bigprimes.pl
SHA1 fe55e27b4791656d36a6c9548280746de7003be5 examples/bigprimes.pl
SHA1 b57b118469a1a16e54d61206c5bd9077dbb2231a examples/hailstone.pl
SHA1 8ca42793d8769ec8d0928f11c30f38d96dd54efb examples/prime.pl
SHA1 7305dbe2904416e28decb05396988a5d51d578be inc/Module/Install.pm
......@@ -41,9 +41,9 @@ SHA1 b721c93ca5bc9a6aa863b49af15f1b1de6125935 inc/Module/Install/Makefile.pm
SHA1 026cc0551a0ad399d195e395b46bdf842e115192 inc/Module/Install/Metadata.pm
SHA1 5457015ea5a50e93465bf2dafa29feebd547f85b inc/Module/Install/Win32.pm
SHA1 051e7fa8063908befa3440508d0584a2497b97db inc/Module/Install/WriteAll.pm
SHA1 0552d20bfb0aadf3ea1753054a386cee9f5e2428 lib/Math/BigFloat.pm
SHA1 81ebbf19f44c571841edded1b210246cb7cec42f lib/Math/BigInt.pm
SHA1 43cc6f40da81ac9f7751348ddab96f6f0123b150 lib/Math/BigInt/Calc.pm
SHA1 59d86282d805f69f7bd2d147c36a853a9064bf29 lib/Math/BigFloat.pm
SHA1 9200a491c734c1061b3e33d7d39559dba95c6c87 lib/Math/BigInt.pm
SHA1 8a715d64481cbb479ebb173828090a684d99906c lib/Math/BigInt/Calc.pm
SHA1 598452b37dbd4bbd2fb4c9cc559e0e0ac91f9bd8 lib/Math/BigInt/CalcEmu.pm
SHA1 63d3ac167c2d98484f521ad9cbddbf306d33d8eb t/Math/BigFloat/Subclass.pm
SHA1 309c0d093884f29111225c2108a33f0e8e028759 t/Math/BigInt/BareCalc.pm
......@@ -51,14 +51,14 @@ SHA1 62deb0b9e3bf94aaf12745207efa3d858f3b878e t/Math/BigInt/Scalar.pm
SHA1 27c1738a064e7f7bf91c762d411af447847c331c t/Math/BigInt/Subclass.pm
SHA1 a2014803baec5dbef46235f83411f76efa0efea7 t/_e_math.t
SHA1 0e725849a20e80bb1da796a7be40b69a958c8313 t/alias.inc
SHA1 55afc3574bff9a49f6f42622b83f6516e6240df9 t/bare_mbf.t
SHA1 7f6941abb43f84eaffb8a65c78ddd0457175f39c t/bare_mbf.t
SHA1 2f18c703ef46afe813b9b8d68f43eca672fcfaab t/bare_mbi.t
SHA1 16793246cd5065cd487fcc62331651c5fc2cbabf t/bare_mif.t
SHA1 333a425247b4e276696210a6322b815a0f55f5ab t/big_pi_e.t
SHA1 f74b5dfb3963b770d376618a6431552e4631fb14 t/bigfltpm.inc
SHA1 9b0690a18d230b1a9a4a45f5a66460bca8c9cb4c t/bigfltpm.t
SHA1 787faf71d064690a0b499f605ba2d03c936e7e1b t/bigintc.t
SHA1 0d3d27246d89ad1eaca8ac1b9895866340ca7a57 t/bigintpm.inc
SHA1 2e61614c1f9c2fa949ff5e9be114a1d33c48dab2 t/bigfltpm.inc
SHA1 e0151e25270c2b0a14955eafe15ab93977af447c t/bigfltpm.t
SHA1 6efb0fd844e25885c310eda19e57a797e127ebc9 t/bigintc.t
SHA1 63fd1d16538a881f04a53cda6752bfc24a482d82 t/bigintpm.inc
SHA1 77b20602f2f164be3d67d7fb8ee8e0bfe43f18d9 t/bigintpm.t
SHA1 cb07d195c20eb306088eeacccc2c7475f267446c t/bigints.t
SHA1 5bdf82ef7085b97caa496bfc71ab1fbfe48ef9e8 t/biglog.t
......@@ -68,14 +68,14 @@ SHA1 c1f7b6840e772f2b6d4f8dbea4c28aaa675c9b17 t/config.t
SHA1 7c75531325efd55f15ef14e5ca22875d6d53e366 t/const_mbf.t
SHA1 b7891121243029ae078ca952205ce3d037b145d8 t/constant.t
SHA1 d5b1f2d01e954a8b0c41d51f79ec878a305cedf7 t/downgrade.t
SHA1 f1845e4a860999b704c3fdb20b6cb6c5d81024f0 t/inf_nan.t
SHA1 3c8e85b53a213c3a0379748726c7907ee2c23adc t/inf_nan.t
SHA1 4ee46eecc74e97f27ef47b208576d179ab01cfb9 t/isa.t
SHA1 95d41431bb5147f2cd97d2f160c1ce220a365142 t/lib_load.t
SHA1 18071d0caf17979c5345baf7b296a1e95d8f9bf1 t/mbf_ali.t
SHA1 79fafec237d6f47d8a176c67418f94c708ed3fec t/mbi_ali.t
SHA1 2b9490eab4d5371b804a39fb16e77c6bd6bbd006 t/mbi_rand.t
SHA1 15e8efc09da6eac8669f3dd3bfd9c1a5f3d7fb42 t/mbimbf.inc
SHA1 d5508ab648eaaf51a99b2f85ccb9be5c1ef0f127 t/mbimbf.t
SHA1 0146ce0a49cef7277e3d009555b60401db222b27 t/mbimbf.inc
SHA1 1a0c8bf7ee5f1c11946974b0ecf4c04346621a33 t/mbimbf.t
SHA1 a8e152beb9c0583cca8ba397ca2952cf456f107c t/nan_cmp.t
SHA1 852bfc6c25fa982e0c48e270277f091732d062e2 t/new_overloaded.t
SHA1 354878333fc3c489b3b6ab73c2923abe81e0ec73 t/pod.t
......@@ -89,12 +89,13 @@ SHA1 ef3834f63ddf05286de80b1d7bb1fb420e117183 t/req_mbfw.t
SHA1 1bbe72733abd2f580f94b6a147672f7671260149 t/require.t
SHA1 ad6cc6fe4bb93ae78db4eb7dcb96c95024b963d2 t/round.t
SHA1 9d51def046889bf20c6ac2a278f9b3f5f8e36025 t/sub_ali.t
SHA1 b0f1b46337df8b05212ada10205839c3f172071e t/sub_mbf.t
SHA1 1e536ee3c640adc80e60f42208a14703ae17d438 t/sub_mbf.t
SHA1 0122fe4c9ecb58e68df90168b2952275c7253af9 t/sub_mbi.t
SHA1 317dd7564b180f5d7b14e4dac64ee90f42317baa t/sub_mif.t
SHA1 22c563a6879c94ce7c8eb72c645f2e374837c34e t/trap.t
SHA1 f8bf42aefd7fed875e4bc6f9e0d3b0f8bf574049 t/upgrade.inc
SHA1 6d12a4d44729cf096c4a22935484ffe72055aaf8 t/upgrade.t
SHA1 e9019081ff5c07957e45619010c62a54472d8508 t/upgrade2.t
SHA1 49183118717b8b90e498b6d7b1ac0aa0e4d85894 t/upgradef.t
SHA1 d58003dbb3ffb469dee56b8c93c5a6b3c353ddb7 t/use.t
SHA1 0c7c020cb79ae009a3a32b411f21a35153c6f776 t/use_lib1.t
......@@ -102,11 +103,11 @@ SHA1 4959257dd52935cdfd17b132e11bcdb4e37752e9 t/use_lib2.t
SHA1 29606835c9d63a19075003429b00947b922ef144 t/use_lib3.t
SHA1 a5cc44a7e485828791696b2b27925e0d2855f883 t/use_lib4.t
SHA1 0c5f496ed66b02d0e118763c91862d84e3fb5629 t/use_mbfw.t
SHA1 b72b5652e970010503c5a6012397e53230d380d3 t/with_sub.t
SHA1 a4034f7f505845dddaaea2540cd376ea66a8650d t/with_sub.t
-----BEGIN PGP SIGNATURE-----
Version: GnuPG v1.4.10 (GNU/Linux)
iEYEARECAAYFAkyhcWsACgkQdC8qQo5jWl6TywCdGNEzJCHRCVbAxXm/xTkzDiMn
K5sAn1dUGyD2GOArptJg7Qk+Lr1/LeUE
=UYvU
iEYEARECAAYFAkzYUnMACgkQdC8qQo5jWl45WQCfcrm062/ZzGiBJtDB/ZiPjCRT
hlYAnRPdE48m/lr7gq1J+I3sdyJ/q78Y
=YE5S
-----END PGP SIGNATURE-----
......@@ -15,7 +15,7 @@ Math::BigFloat:
* tests for frsft() and flsft() with $n != 2
* blog() is still quite slow for non-integer results. See if we can reuse the
integer calculation somehow
* finish broot() by using different algorithmn
* finish broot() by using different algorithm
* hexadecimal integers work, but what about '0xABC.DEF'? Really needed?
Math::BigInt:
......@@ -38,7 +38,7 @@ Math::BigInt:
$x->bsqrt(3,0,'odd'); # $x = 0, but _a is not 3!
ok ($x + '12345','12300'); # fails (12346 instead of 12300)
The shortcuts in code that return $x->bzero() or similiar things need to
The shortcuts in code that return $x->bzero() or similar things need to
do $x->bzero($a,$p); and this needs tests.
Update: Should now work for most things. Check for completeness.
......
......@@ -22,7 +22,7 @@ my ($x,$y,$z);
my $two = Math::BigInt->new(2);
# some new() are to make stop Perl from calculating things like 1234 ** 4321
# at compile time. (we want to see run-time behaviuor)
# at compile time. (we want to see run-time behaviour)
# Also there is len(), since the old BigInt has not got length() and we want
# this script to be comparable between old and new version.
......@@ -63,7 +63,7 @@ ok (len($q[2]),'1031');
ok (len($q[3]),'1031');
##############################################################################
# some real wierd primes:
# some real weird primes:
# (2^3833-1)/(14193959303*340789152474053904109001)
$x = Math::BigInt->new('340789152474053904109001');
......
......@@ -12,7 +12,7 @@ package Math::BigFloat;
# _a : accuracy
# _p : precision
$VERSION = '1.63';
$VERSION = '1.64';
require 5.006002;
require Exporter;
......@@ -149,7 +149,7 @@ sub new
$self->{sign} = $wanted->sign();
return $self->bnorm();
}
# else: got a string or something maskerading as number (with overload)
# else: got a string or something masquerading as number (with overload)
# handle '+inf', '-inf' first
if ($wanted =~ /^[+-]?inf\z/)
......@@ -353,7 +353,7 @@ sub config
}
##############################################################################
# string conversation
# string conversion
sub bstr
{
......@@ -1141,7 +1141,7 @@ sub _log
# in case of $x == 1, result is 0
return $x->bzero() if $x->is_one();
# XXX TODO: rewrite this in a similiar manner to bexp()
# XXX TODO: rewrite this in a similar manner to bexp()
# http://www.efunda.com/math/taylor_series/logarithmic.cfm?search_string=log
......@@ -2128,7 +2128,7 @@ sub bsqrt
}
# sqrt(2) = 1.4 because sqrt(2*100) = 1.4*10; so we can increase the accuracy
# of the result by multipyling the input by 100 and then divide the integer
# of the result by multiplying the input by 100 and then divide the integer
# result of sqrt(input) by 10. Rounding afterwards returns the real result.
# The following steps will transform 123.456 (in $x) into 123456 (in $y1)
......@@ -3684,6 +3684,9 @@ sub as_number
$x = $x->can('as_float') ? $x->as_float() : $self->new(0+"$x");
}
return Math::BigInt->binf($x->sign()) if $x->is_inf();
return Math::BigInt->bnan() if $x->is_nan();
my $z = $MBI->_copy($x->{_m});
if ($x->{_es} eq '-') # < 0
{
......@@ -3943,7 +3946,7 @@ Since things like C<sqrt(2)> or C<1 / 3> must presented with a limited
accuracy lest a operation consumes all resources, each operation produces
no more than the requested number of digits.
If there is no gloabl precision or accuracy set, B<and> the operation in
If there is no global precision or accuracy set, B<and> the operation in
question was not called with a requested precision or accuracy, B<and> the
input $x has no accuracy or precision set, then a fallback parameter will
be used. For historical reasons, it is called C<div_scale> and can be accessed
......
......@@ -6,7 +6,7 @@ package Math::BigInt;
#
# The following hash values are used:
# value: unsigned int with actual value (as a Math::BigInt::Calc or similiar)
# value: unsigned int with actual value (as a Math::BigInt::Calc or similar)
# sign : +,-,NaN,+inf,-inf
# _a : accuracy
# _p : precision
......@@ -18,7 +18,7 @@ package Math::BigInt;
my $class = "Math::BigInt";
use 5.006002;
$VERSION = '1.96';
$VERSION = '1.98';
@ISA = qw(Exporter);
@EXPORT_OK = qw(objectify bgcd blcm);
......@@ -799,7 +799,7 @@ sub bone
}
##############################################################################
# string conversation
# string conversion
sub bsstr
{
......@@ -1787,7 +1787,7 @@ sub bmodinv
{
# Modular inverse. given a number which is (hopefully) relatively
# prime to the modulus, calculate its inverse using Euclid's
# alogrithm. If the number is not relatively prime to the modulus
# algorithm. If the number is not relatively prime to the modulus
# (i.e. their gcd is not one) then NaN is returned.
# set up parameters
......@@ -2559,7 +2559,7 @@ sub objectify
{
$k = $a[0]->new($k);
}
elsif (!defined $up && ref($k) ne $a[0])
elsif (ref($k) ne $a[0] and !defined $up || ref $k ne $up)
{
# foreign object, try to convert to integer
$k->can('as_number') ? $k = $k->as_number() : $k = $a[0]->new($k);
......@@ -3099,7 +3099,7 @@ Math::BigInt - Arbitrary size integer/float math package
# will warn if Math::BigInt::GMP cannot be found
use Math::BigInt lib => 'GMP';
# to supress the warning use this:
# to suppress the warning use this:
# use Math::BigInt try => 'GMP';
# dies if GMP cannot be loaded:
......@@ -3230,7 +3230,7 @@ Math::BigInt - Arbitrary size integer/float math package
$x->as_int(); # return as BigInt (in BigInt: same as copy())
$x->numify(); # return as scalar (might overflow!)
# conversation to string (do not modify their argument)
# conversion to string (do not modify their argument)
$x->bstr(); # normalized string (e.g. '3')
$x->bsstr(); # norm. string in scientific notation (e.g. '3E0')
$x->as_hex(); # as signed hexadecimal string with prefixed 0x
......@@ -3269,7 +3269,7 @@ Input values to these routines may be any string, that looks like a number
and results in an integer, including hexadecimal and binary numbers.
Scalars holding numbers may also be passed, but note that non-integer numbers
may already have lost precision due to the conversation to float. Quote
may already have lost precision due to the conversion to float. Quote
your input if you want BigInt to see all the digits:
$x = Math::BigInt->new(12345678890123456789); # bad
......@@ -3508,7 +3508,7 @@ See L<Input> for more info on accepted input formats.
=head2 from_bin()
$x = Math::BigInt->from_bin("0x10011"); # input is binary
$x = Math::BigInt->from_bin("0b10011"); # input is binary
=head2 bnan()
......@@ -3988,7 +3988,7 @@ This loses precision, to avoid this use L<as_int()> instead.
$x->modify('bpowd');
This method returns 0 if the object can be modified with the given
peration, or 1 if not.
operation, or 1 if not.
This is used for instance by L<Math::BigInt::Constant>.
......@@ -4715,7 +4715,7 @@ As a shortcut, you can use the module C<bignum>:
use bignum;
Also good for oneliners:
Also good for one-liners:
perl -Mbignum -le 'print 2 ** 255'
......@@ -4877,7 +4877,7 @@ instead.
The quotient is always the greatest integer less than or equal to the
real-valued quotient of the two operands, and the remainder (when it is
nonzero) always has the same sign as the second operand; so, for
non-zero) always has the same sign as the second operand; so, for
example,
1 / 4 => ( 0, 1)
......
......@@ -4,7 +4,7 @@ use 5.006002;
use strict;
# use warnings; # dont use warnings for older Perls
our $VERSION = '0.55';
our $VERSION = '0.57';
# Package to store unsigned big integers in decimal and do math with them
......@@ -60,7 +60,7 @@ sub _base_len
$BASE = int("1e".$BASE_LEN);
$MAX_VAL = $BASE-1;
return $BASE_LEN unless wantarray;
return ($BASE_LEN, $AND_BITS, $XOR_BITS, $OR_BITS, $BASE_LEN, $MAX_VAL, $BASE);
return ($BASE_LEN, $BASE, $AND_BITS, $XOR_BITS, $OR_BITS, $BASE_LEN, $MAX_VAL,);
}
# find whether we can use mul or div in mul()/div()
......@@ -95,7 +95,7 @@ sub _base_len
}
}
return $BASE_LEN unless wantarray;
return ($BASE_LEN, $AND_BITS, $XOR_BITS, $OR_BITS, $BASE_LEN, $MAX_VAL, $BASE);
return ($BASE_LEN, $BASE, $AND_BITS, $XOR_BITS, $OR_BITS, $BASE_LEN, $MAX_VAL);
}
sub _new
......@@ -189,7 +189,7 @@ BEGIN
$XOR_MASK = __PACKAGE__->_new( ( 2 ** $XOR_BITS ));
$OR_MASK = __PACKAGE__->_new( ( 2 ** $OR_BITS ));
# We can compute the approximate lenght no faster than the real length:
# We can compute the approximate length no faster than the real length:
*_alen = \&_len;
}
......@@ -595,7 +595,7 @@ sub _div_use_mul
my ($c,$x,$yorg) = @_;
# the general div algorithmn here is about O(N*N) and thus quite slow, so
# the general div algorithm here is about O(N*N) and thus quite slow, so
# we first check for some special cases and use shortcuts to handle them.
# This works, because we store the numbers in a chunked format where each
......@@ -785,7 +785,7 @@ sub _div_use_div_64
my ($c,$x,$yorg) = @_;
use integer;
# the general div algorithmn here is about O(N*N) and thus quite slow, so
# the general div algorithm here is about O(N*N) and thus quite slow, so
# we first check for some special cases and use shortcuts to handle them.
# This works, because we store the numbers in a chunked format where each
......@@ -976,7 +976,7 @@ sub _div_use_div
# in list context
my ($c,$x,$yorg) = @_;
# the general div algorithmn here is about O(N*N) and thus quite slow, so
# the general div algorithm here is about O(N*N) and thus quite slow, so
# we first check for some special cases and use shortcuts to handle them.
# This works, because we store the numbers in a chunked format where each
......@@ -1206,20 +1206,18 @@ sub _len
sub _digit
{
# return the nth digit, negative values count backward
# zero is rightmost, so _digit(123,0) will give 3
# Return the nth digit. Zero is rightmost, so _digit(123,0) gives 3.
# Negative values count from the left, so _digit(123, -1) gives 1.
my ($c,$x,$n) = @_;
my $len = _len('',$x);
$n = $len+$n if $n < 0; # -1 last, -2 second-to-last
$n = abs($n); # if negative was too big
$len--; $n = $len if $n > $len; # n to big?
my $elem = int($n / $BASE_LEN); # which array element
my $digit = $n % $BASE_LEN; # which digit in this element
$elem = '0' x $BASE_LEN . @$x[$elem]; # get element padded with 0's
substr($elem,-$digit-1,1);
$n += $len if $n < 0; # -1 last, -2 second-to-last
return "0" if $n < 0 || $n >= $len; # return 0 for digits out of range
my $elem = int($n / $BASE_LEN); # which array element
my $digit = $n % $BASE_LEN; # which digit in this element
substr("$x->[$elem]", -$digit-1, 1);
}
sub _zeros
......@@ -2028,7 +2026,7 @@ sub _root
# reset step to 2
$step = _two();
# add two, because $trial cannot be exactly the result (otherwise we would
# alrady have found it)
# already have found it)
_add($c, $trial, $step);
# and now add more and more (2,4,6,8,10 etc)
......
#!/usr/bin/perl -w
use strict;
use Test::More tests => 2316;
use Test::More tests => 2319;
BEGIN { unshift @INC, 't'; }
......
......@@ -587,6 +587,9 @@ fnormNaN:NaN
-2:-2
-123.456:-123
-200:-200
-inf:-inf
inf:inf
NaN:NaN
# test for bug in brsft() not handling cases that return 0
0.000641:0
0.0006412:0
......
#!/usr/bin/perl -w
use strict;
use Test::More tests => 2316
use Test::More tests => 2319
+ 5; # own tests
......
#!/usr/bin/perl -w
use strict;
use Test::More tests => 375;
use Test::More tests => 379;
use Math::BigInt::Calc;
my ($BASE_LEN, $AND_BITS, $XOR_BITS, $OR_BITS, $BASE_LEN_SMALL, $MAX_VAL) =
my ($BASE_LEN, undef, $AND_BITS, $XOR_BITS, $OR_BITS, $BASE_LEN_SMALL, $MAX_VAL) =
Math::BigInt::Calc->_base_len();
print "# BASE_LEN = $BASE_LEN\n";
......@@ -129,9 +129,13 @@ $x = $C->_new("123456789");
is ($C->_digit($x,0),9);
is ($C->_digit($x,1),8);
is ($C->_digit($x,2),7);
is ($C->_digit($x,8),1);
is ($C->_digit($x,9),0);
is ($C->_digit($x,-1),1);
is ($C->_digit($x,-2),2);
is ($C->_digit($x,-3),3);
is ($C->_digit($x,-9),9);
is ($C->_digit($x,-10),0);
# _copy
foreach (qw/ 1 12 123 1234 12345 123456 1234567 12345678 123456789/)
......
......@@ -443,7 +443,7 @@ $z = 1e+129; # definitely a float (may fail on UTS)
$x = $class->new($z); is ($x->bsstr(),'1e+129');
###############################################################################
# test for whitespace inlcuding newlines to be handled correctly
# test for whitespace including newlines to be handled correctly
# is ($Math::BigInt::strict,1); # the default
......@@ -525,7 +525,7 @@ $x = $class->new('+inf'); is ($x,'inf');
###############################################################################
###############################################################################
# the followin tests only make sense with Math::BigInt::Calc or BareCalc or
# the following tests only make sense with Math::BigInt::Calc or BareCalc or
# FastCalc
exit if $CALC !~ /^Math::BigInt::(|Bare|Fast)Calc$/; # for Pari et al.
......@@ -583,7 +583,7 @@ is ($x, 23456);
# construct a number with a zero-hole of BASE_LEN_SMALL
{
my @bl = $CL->_base_len(); my $bl = $bl[4];
my @bl = $CL->_base_len(); my $bl = $bl[5];
$x = '1' x $bl . '0' x $bl . '1' x $bl . '0' x $bl;
$y = '1' x (2*$bl);
......
......@@ -303,7 +303,7 @@ foreach (qw/
}
#############################################################################
# overloaded comparisations
# overloaded comparisons
# these are disabled for now, since Perl itself can't seem to make up it's
# mind what NaN actually is, see [perl #33106].
......
......@@ -280,8 +280,8 @@ foreach my $c ($mbi,$mbf)
$x = $mbf->new('123.456');
$y = $mbf->new('654.321');
$x->{_a} = 5; # $x->accuracy(5) would round $x straightaway
$y->{_a} = 4; # $y->accuracy(4) would round $x straightaway
$x->{_a} = 5; # $x->accuracy(5) would round $x straight away
$y->{_a} = 4; # $y->accuracy(4) would round $x straight away
$z = $x + $y; is ($z,'777.8');
$z = $y - $x; is ($z,'530.9');
......@@ -296,8 +296,8 @@ $z = $x->copy; $z++; is ($z,123500);
$x = $mbi->new(123456);
$y = $mbi->new(654321);
$x->{_a} = 5; # $x->accuracy(5) would round $x straightaway
$y->{_a} = 4; # $y->accuracy(4) would round $x straightaway
$x->{_a} = 5; # $x->accuracy(5) would round $x straight away
$y->{_a} = 4; # $y->accuracy(4) would round $x straight away
$z = $x + $y; is ($z,777800);
$z = $y - $x; is ($z,530900);
......@@ -590,7 +590,7 @@ is ($x->{_a}, undef); is ($x->{_p}, undef);
is ($y->{_a}, undef); is ($y->{_p}, undef);
###############################################################################
# math with two numbers with differen A and P
# math with two numbers with different A and P
$x = $mbf->new(12345); $x->accuracy(4); # '12340'
$y = $mbf->new(12345); $y->accuracy(2); # '12000'
......
......@@ -18,7 +18,7 @@ $mbf = 'Math::BigFloat';
require 't/mbimbf.inc';
# some tests that won't work with subclasses, since the things are only
# garantied in the Math::BigInt/BigFloat (unless subclass chooses to support
# guaranteed in the Math::BigInt/BigFloat (unless subclass chooses to support
# this)
Math::BigInt->round_mode('even'); # reset for tests
......
#!/usr/bin/perl -w
use strict;
use Test::More tests => 2316
use Test::More tests => 2319
+ 6; # + our own tests
......
#!/usr/bin/perl -w
# Test 2 levels of upgrade classes. This used to cause a segv.
use Test::More tests => 1;
use Math::BigInt upgrade => 'Math::BigFloat';
use Math::BigFloat upgrade => 'Math::BigMouse';
no warnings 'once';
@Math::BigMouse::ISA = 'Math::BigFloat';
() = sqrt Math::BigInt->new(2);
pass('sqrt on a big int does not segv if there are 2 upgrade levels');
......@@ -3,7 +3,7 @@
# Test use Math::BigFloat with => 'Math::BigInt::SomeSubclass';
use strict;
use Test::More tests => 2316 + 1;
use Test::More tests => 2319 + 1;
use Math::BigFloat with => 'Math::BigInt::Subclass', lib => 'Calc';
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment