{
$try .= "\$x >> \$y;";
}
+ }elsif ($f eq "broot"){
+ $try .= "\$x->broot(\$y);";
+ }elsif ($f eq "blog"){
+ $try .= "\$x->blog(\$y);";
}elsif ($f eq "band"){
$try .= "\$x & \$y;";
}elsif ($f eq "bior"){
($x,$y) = $x->length();
ok ($x,13); ok ($y,0);
+# test <<=, >>=
+$x = $class->new('2');
+my $y = $class->new('18');
+ok ($x <<= $y, 2 << 18);
+ok ($x, 2 << 18);
+ok ($x >>= $y, 2);
+ok ($x, 2);
+
# I am afraid the following is not yet possible due to slowness
# Also, testing for 2 meg output is a bit hard ;)
#$x = $class->new(2); $x **= 6972593; $x--;
ok ($class->binf('-inf'),'-inf');
###############################################################################
+# is_one('-')
+
+ok ($class->new(1)->is_one('-'),0);
+ok ($class->new(-1)->is_one('-'),1);
+ok ($class->new(1)->is_one(),1);
+ok ($class->new(-1)->is_one(),0);
+
+###############################################################################
+# [perl #30609] bug with $x -= $x not beeing 0, but 2*$x
+
+$x = $class->new(3); $x -= $x; ok ($x, 0);
+$x = $class->new(-3); $x -= $x; ok ($x, 0);
+$x = $class->new('NaN'); $x -= $x; ok ($x->is_nan(), 1);
+$x = $class->new('inf'); $x -= $x; ok ($x->is_nan(), 1);
+$x = $class->new('-inf'); $x -= $x; ok ($x->is_nan(), 1);
+
+$x = $class->new('NaN'); $x += $x; ok ($x->is_nan(), 1);
+$x = $class->new('inf'); $x += $x; ok ($x->is_inf(), 1);
+$x = $class->new('-inf'); $x += $x; ok ($x->is_inf('-'), 1);
+$x = $class->new(3); $x += $x; ok ($x, 6);
+$x = $class->new(-3); $x += $x; ok ($x, -6);
+
+$x = $class->new(3); $x *= $x; ok ($x, 9);
+$x = $class->new(-3); $x *= $x; ok ($x, 9);
+$x = $class->new(3); $x /= $x; ok ($x, 1);
+$x = $class->new(-3); $x /= $x; ok ($x, 1);
+$x = $class->new(3); $x %= $x; ok ($x, 0);
+$x = $class->new(-3); $x %= $x; ok ($x, 0);
+
+###############################################################################
# all tests done
1;
5:7:5
&^=
5:7:2
+&blog
+NaNlog:2:NaN
+122:NaNlog:NaN
+NaNlog1:NaNlog:NaN
+122:inf:NaN
+inf:122:NaN
+122:-inf:NaN
+-inf:122:NaN
+-inf:-inf:NaN
+inf:inf:NaN
+0:4:NaN
+-21:4:NaN
+21:-21:NaN
+# normal results
+1024:2:10
+81:3:4
+# 3.01.. truncate
+82:3:4
+# 3.9... truncate
+80:3:3
+15625:5:6
+15626:5:6
+15624:5:5
+1000:10:3
+10000:10:4
+100000:10:5
+1000000:10:6
+10000000:10:7
+100000000:10:8
+8916100448256:12:12
+8916100448257:12:12
+8916100448255:12:11
+2251799813685248:8:17
+72057594037927936:2:56
+144115188075855872:2:57
+288230376151711744:2:58
+576460752303423488:2:59
+4096:2:12
+1329227995784915872903807060280344576:2:120
+# $x == $base => result 1
+3:3:1
+# $x < $base => result 0 ($base ** 0 <= $x)
+3:4:0
+# $x == 1 => result 0
+1:5:0
&is_negative
0:0
-1:1
-inf:1
NaNneg:0
&is_positive
-0:1
+0:0
-1:0
1:1
+inf:1
-inf:123:1
+inf:-123:1
-inf:-123:1
+123:-inf:-1
+-123:inf:-1
+-123:-inf:-1
+123:inf:-1
# return undef
+inf:NaN:
NaN:inf:
-inf:NaN:
NaN:-inf:
&bnorm
+0e999:0
+0e-999:0
+-0e999:0
+-0e-999:0
123:123
# binary input
0babc:NaN
0x200000001:8589934593
0x400000001:17179869185
0x800000001:34359738369
+# bug found by Mark Lakata in Calc.pm creating too big one-element numbers in _from_hex()
+0x2dd59e18a125dbed30a6ab1d93e9c855569f44f75806f0645dc9a2e98b808c3:1295719234436071846486578237372801883390756472611551858964079371952886122691
# inf input
inf:inf
+inf:inf
012345678912:12345678912
0123456789123:123456789123
01234567891234:1234567891234
+# some inputs that result in zero
+0e0:0
++0e0:0
++0e+0:0
+-0e+0:0
+0e-0:0
+-0e-0:0
++0e-0:0
+000:0
+00e2:0
+00e02:0
+000e002:0
+000e1230:0
+00e-3:0
+00e+3:0
+00e-03:0
+00e+03:0
+-000:0
+-00e2:0
+-00e02:0
+-000e002:0
+-000e1230:0
+-00e-3:0
+-00e+3:0
+-00e-03:0
+-00e+03:0
# normal input
0:0
+0:0
-8:0:-inf,-8
-inf:0:-inf,-inf
0:0:NaN,NaN
+# test the shortcut in Calc if @$x == @$yorg
+1234567812345678:123456712345678:10,688888898
+12345671234567:1234561234567:10,58888897
+123456123456:12345123456:10,4888896
+1234512345:123412345:10,388895
+1234567890999999999:1234567890:1000000000,999999999
+1234567890000000000:1234567890:1000000000,0
+1234567890999999999:9876543210:124999998,9503086419
+1234567890000000000:9876543210:124999998,8503086420
+96969696969696969696969696969678787878626262626262626262626262:484848484848484848484848486666666666666689898989898989898989:199,484848484848484848484848123012121211954972727272727272727451
+# bug in v1.76
+1267650600228229401496703205375:1267650600228229401496703205376:0,1267650600228229401496703205375
+# excercise shortcut for numbers of the same length in div
+999999999999999999999999999999999:999999999999999999999999999999999:1,0
+999999999999999999999999999999999:888888888888888888888888888888888:1,111111111111111111111111111111111
+999999999999999999999999999999999:777777777777777777777777777777777:1,222222222222222222222222222222222
+999999999999999999999999999999999:666666666666666666666666666666666:1,333333333333333333333333333333333
+999999999999999999999999999999999:555555555555555555555555555555555:1,444444444444444444444444444444444
+999999999999999999999999999999999:444444444444444444444444444444444:2,111111111111111111111111111111111
+999999999999999999999999999999999:333333333333333333333333333333333:3,0
+999999999999999999999999999999999:222222222222222222222222222222222:4,111111111111111111111111111111111
+999999999999999999999999999999999:111111111111111111111111111111111:9,0
+9999999_9999999_9999999_9999999:3333333_3333333_3333333_3333333:3,0
+9999999_9999999_9999999_9999999:3333333_0000000_0000000_0000000:3,999999999999999999999
+9999999_9999999_9999999_9999999:3000000_0000000_0000000_0000000:3,999999999999999999999999999
+9999999_9999999_9999999_9999999:2000000_0000000_0000000_0000000:4,1999999999999999999999999999
+9999999_9999999_9999999_9999999:1000000_0000000_0000000_0000000:9,999999999999999999999999999
+9999999_9999999_9999999_9999999:100000_0000000_0000000_0000000:99,99999999999999999999999999
+9999999_9999999_9999999_9999999:10000_0000000_0000000_0000000:999,9999999999999999999999999
+9999999_9999999_9999999_9999999:1000_0000000_0000000_0000000:9999,999999999999999999999999
+9999999_9999999_9999999_9999999:100_0000000_0000000_0000000:99999,99999999999999999999999
+9999999_9999999_9999999_9999999:10_0000000_0000000_0000000:999999,9999999999999999999999
+9999999_9999999_9999999_9999999:1_0000000_0000000_0000000:9999999,999999999999999999999
&bdiv
abc:abc:NaN
abc:1:NaN
14:3:4
# bug in Calc with '99999' vs $BASE-1
10000000000000000000000000000000000000000000000000000000000000000000000000000000000:10000000375084540248994272022843165711074:999999962491547381984643365663244474111576
+# test the shortcut in Calc if @$x == @$yorg
+1234567812345678:123456712345678:10
+12345671234567:1234561234567:10
+123456123456:12345123456:10
+1234512345:123412345:10
+1234567890999999999:1234567890:1000000000
+1234567890000000000:1234567890:1000000000
+1234567890999999999:9876543210:124999998
+1234567890000000000:9876543210:124999998
+96969696969696969696969696969678787878626262626262626262626262:484848484848484848484848486666666666666689898989898989898989:199
+# bug up to v0.35 in Calc (--$q one too many)
+84696969696969696956565656566184292929292929292847474747436308080808080808086765396464646464646465:13131313131313131313131313131394949494949494949494949494943535353535353535353535:6449999999999999999
+84696969696969696943434343434871161616161616161452525252486813131313131313143230042929292929292930:13131313131313131313131313131394949494949494949494949494943535353535353535353535:6449999999999999998
+84696969696969696969696969697497424242424242424242424242385803030303030303030300750000000000000000:13131313131313131313131313131394949494949494949494949494943535353535353535353535:6450000000000000000
+84696969696969696930303030303558030303030303030057575757537318181818181818199694689393939393939395:13131313131313131313131313131394949494949494949494949494943535353535353535353535:6449999999999999997
+# excercise shortcut for numbers of the same length in div
+999999999999999999999999999999999:999999999999999999999999999999999:1
+999999999999999999999999999999999:888888888888888888888888888888888:1
+999999999999999999999999999999999:777777777777777777777777777777777:1
+999999999999999999999999999999999:666666666666666666666666666666666:1
+999999999999999999999999999999999:555555555555555555555555555555555:1
+999999999999999999999999999999999:444444444444444444444444444444444:2
+999999999999999999999999999999999:333333333333333333333333333333333:3
+999999999999999999999999999999999:222222222222222222222222222222222:4
+999999999999999999999999999999999:111111111111111111111111111111111:9
+9999999_9999999_9999999_9999999:3333333_3333333_3333333_3333333:3
+9999999_9999999_9999999_9999999:3333333_0000000_0000000_0000000:3
+9999999_9999999_9999999_9999999:3000000_0000000_0000000_0000000:3
+9999999_9999999_9999999_9999999:2000000_0000000_0000000_0000000:4
+9999999_9999999_9999999_9999999:1000000_0000000_0000000_0000000:9
+9999999_9999999_9999999_9999999:100000_0000000_0000000_0000000:99
+9999999_9999999_9999999_9999999:10000_0000000_0000000_0000000:999
+9999999_9999999_9999999_9999999:1000_0000000_0000000_0000000:9999
+9999999_9999999_9999999_9999999:100_0000000_0000000_0000000:99999
+9999999_9999999_9999999_9999999:10_0000000_0000000_0000000:999999
+9999999_9999999_9999999_9999999:1_0000000_0000000_0000000:9999999
+# bug with shortcut in Calc 0.44
+949418181818187070707070707070707070:181818181853535353535353535353535353:5
&bmodinv
# format: number:modulus:result
# bmodinv Data errors
123456789123456789:113:39
# bug in bmod() not modifying the variable in place
-629:5033:4404
+# bug in bmod() in Calc in the _div_use_div() shortcut code path,
+# when X == X and X was big
+111111111111111111111111111111:111111111111111111111111111111:0
+12345678901234567890:12345678901234567890:0
&bgcd
+inf:12:NaN
+-inf:12:NaN
+12:inf:NaN
+12:-inf:NaN
+inf:inf:NaN
+inf:-inf:NaN
+-inf:-inf:NaN
abc:abc:NaN
abc:+0:NaN
+0:abc:NaN
+2:+3:1
+3:+2:1
-3:+2:1
+-3:-2:1
+-144:-60:12
+144:-60:12
+144:60:12
100:625:25
4096:81:1
1034:804:2
+281474976710656:0:0
+281474976710656:1:0
+281474976710656:+281474976710656:281474976710656
+281474976710656:-1:281474976710656
-2:-3:-4
-1:-1:-1
-6:-6:-6
-7:-4:-8
-7:4:0
-4:7:4
+# negative argument is bitwise shorter than positive [perl #26559]
+30:-3:28
+123:-1:123
# equal arguments are treated special, so also do some test with unequal ones
0xFFFF:0xFFFF:0x0xFFFF
0xFFFFFF:0xFFFFFF:0x0xFFFFFF
-6:-6:-6
-7:4:-3
-4:7:-1
++281474976710656:-1:-1
+30:-3:-1
+30:-4:-2
+300:-76:-68
+-76:300:-68
# equal arguments are treated special, so also do some test with unequal ones
0xFFFF:0xFFFF:0x0xFFFF
0xFFFFFF:0xFFFFFF:0x0xFFFFFF
-4:7:-5
4:-7:-3
-4:-7:5
+30:-3:-29
+30:-4:-30
+300:-76:-360
+-76:300:-360
# equal arguments are treated special, so also do some test with unequal ones
0xFFFF:0xFFFF:0
0xFFFFFF:0xFFFFFF:0
&bfac
-1:NaN
NaNfac:NaN
-+inf:NaN
++inf:inf
-inf:NaN
0:1
1:1
4:24
5:120
6:720
+7:5040
+8:40320
+9:362880
10:3628800
11:39916800
12:479001600
0:0:1
0:1:0
0:2:0
-0:-1:NaN
-0:-2:NaN
+0:-1:inf
+0:-2:inf
1:0:1
1:1:1
1:2:1
2:2:4
2:3:8
3:3:27
+-2:2:4
+-2:3:-8
+-2:4:16
+-2:5:-32
2:-1:NaN
-2:-1:NaN
2:-2:NaN
-2:-2:NaN
+# inf tests
+inf:1234500012:inf
--inf:1234500012:-inf
+-inf:1234500012:inf
+-inf:1234500013:-inf
+inf:-12345000123:inf
-inf:-12345000123:-inf
+# -inf * -inf = inf
+-inf:2:inf
+-inf:0:NaN
+-inf:-1:0
+-inf:inf:NaN
+2:inf:inf
+2:-inf:0
+0:inf:0
+0:-inf:inf
+-1:-inf:NaN
+-1:inf:NaN
+-2:inf:NaN
+-2:-inf:0
+NaN:inf:NaN
+NaN:-inf:NaN
+-inf:NaN:NaN
+inf:NaN:NaN
+inf:-inf:NaN
+1:inf:1
+1:-inf:1
# 1 ** -x => 1 / (1 ** x)
-1:0:1
-2:0:1
10:9:1000000000
10:20:100000000000000000000
123456:2:15241383936
+-2:2:4
+-2:3:-8
+-2:4:16
+-2:5:-32
+-3:2:9
+-3:3:-27
+-3:4:81
+-3:5:-243
&length
100:3
10:2
10000000000000000:17
-123:3
215960156869840440586892398248:30
+&broot
+# sqrt()
++0:2:0
++1:2:1
+-1:2:NaN
+# -$x ** (1/2) => -$y, but not in froot()
+-123:2:NaN
++inf:2:inf
+-inf:2:NaN
+2:2:1
+-2:2:NaN
+4:2:2
+9:2:3
+16:2:4
+100:2:10
+123:2:11
+15241:2:123
+144:2:12
+12:2:3
+0.49:2:0
+0.0049:2:0
+# invalid ones
+1:NaN:NaN
+-1:NaN:NaN
+0:NaN:NaN
+-inf:NaN:NaN
++inf:NaN:NaN
+NaN:0:NaN
+NaN:2:NaN
+NaN:inf:NaN
+NaN:inf:NaN
+12:-inf:NaN
+12:inf:NaN
++0:0:NaN
++1:0:NaN
+-1:0:NaN
+-2:0:NaN
+-123.45:0:NaN
++inf:0:NaN
+12:1:12
+-12:1:NaN
+8:-1:NaN
+-8:-1:NaN
+# cubic root
+8:3:2
+-8:3:NaN
+# fourths root
+16:4:2
+81:4:3
+# 2 ** 64
+18446744073709551616:4:65536
+18446744073709551616:8:256
+18446744073709551616:16:16
+18446744073709551616:32:4
+18446744073709551616:64:2
+18446744073709551616:128:1
+# 213 ** 15
+84274086103068221283760416414557757:15:213
+# see t/bigroot for more tests
&bsqrt
145:12
144:12
152399026:12345
152399025:12345
152399024:12344
+# 2 ** 64 => 2 ** 32
+18446744073709551616:4294967296
+84274086103068221283760416414557757:290299993288095377
1:1
0:0
-2:NaN
-123:NaN
Nan:NaN
-+inf:NaN
++inf:inf
+-inf:NaN
&bround
$round_mode('trunc')
0:12:0