From 79c55733ce6421e125458aa172bb5ad38102bc29 Mon Sep 17 00:00:00 2001 From: Jarkko Hietaniemi Date: Mon, 4 Mar 2002 02:07:06 +0000 Subject: [PATCH] Forgot from the M::BI 1.54 update. p4raw-id: //depot/perl@14977 --- lib/Math/BigInt/t/bigfltpm.inc | 11 +++-- lib/Math/BigInt/t/bigintpm.inc | 5 +++ lib/Math/BigInt/t/upgrade.inc | 97 +++++++++++++++++++++++------------------- 3 files changed, 67 insertions(+), 46 deletions(-) diff --git a/lib/Math/BigInt/t/bigfltpm.inc b/lib/Math/BigInt/t/bigfltpm.inc index 17a6783..8748d23 100644 --- a/lib/Math/BigInt/t/bigfltpm.inc +++ b/lib/Math/BigInt/t/bigfltpm.inc @@ -202,22 +202,23 @@ $div_scale = 40; -2:NaN 1:0 # this is too slow for the testsuite +#2:0.6931471805599453094172321214581765680755 #2.718281828:0.9999999998311266953289851340574956564911 #$div_scale = 20; #2.718281828:0.99999999983112669533 -1:0 # too slow, too (or hangs?) #123:4.8112184355 -# $div_scale = 14; +$div_scale = 14; #10:0:2.302585092994 #1000:0:6.90775527898214 #100:0:4.60517018598809 -#2:0:0.693147180559945 +2:0:0.69314718055995 #3.1415:0:1.14470039286086 #12345:0:9.42100640177928 #0.001:0:-6.90775527898214 # reset for further tests $div_scale = 40; +1:0 &frsft NaNfrsft:2:NaN 0:2:0 @@ -366,6 +367,10 @@ abc:123.456:NaN -inf:123.45:-inf +inf:-123.45:inf -inf:-123.45:-inf +# 2 ** 0.5 == sqrt(2) +# 1.41..7 and not 1.4170 since fallback (bsqrt(9) is '3', not 3.0...0) +2:0.5:1.41421356237309504880168872420969807857 +2:0.2:1.148698354997035006798626946777927589444 &fneg fnegNaN:NaN +inf:-inf diff --git a/lib/Math/BigInt/t/bigintpm.inc b/lib/Math/BigInt/t/bigintpm.inc index 8fb7554..39f4c77 100644 --- a/lib/Math/BigInt/t/bigintpm.inc +++ b/lib/Math/BigInt/t/bigintpm.inc @@ -489,6 +489,7 @@ $x = $class->new('-322056000'); ($x,$y) = $x->bdiv('-12882240'); ok ($y,'0'); is_valid($y); # $y not '-0' +############################################################################### # all tests done 1; @@ -836,6 +837,10 @@ NaN::0 +inf:+:1 -inf:-:1 -inf:+:0 +-inf:-inf:1 +-inf:+inf:0 ++inf:-inf:0 ++inf:+inf:1 # it must be exactly /^[+-]inf$/ +infinity::0 -infinity::0 diff --git a/lib/Math/BigInt/t/upgrade.inc b/lib/Math/BigInt/t/upgrade.inc index 6dcaa75..26b3a65 100644 --- a/lib/Math/BigInt/t/upgrade.inc +++ b/lib/Math/BigInt/t/upgrade.inc @@ -3,9 +3,12 @@ # This file is nearly identical to bigintpm.t, except that certain results # are _requird_ to be different due to "upgrading" or "promoting" to BigFloat. # The reverse is not true, any unmarked results can be either BigInt or -# BigFloat, depending on how good the internal optimization is. +# BigFloat, depending on how good the internal optimization is (e.g. it +# is usually desirable to have 2 ** 2 return an BigInt, not an BigFloat). -# Plaese note that the testcount goes up by two for each extra result marked +# Results that are required to be BigFloat are marked with an "^" at the end. + +# Please note that the testcount goes up by two for each extra result marked # with ^, since then we test whether it has the proper class and that it left # the upgrade variable alone. @@ -101,7 +104,14 @@ while () $try .= '$e = $e->bstr(); $e = "NaN" if !defined $e;'; $try .= '"$m,$e";'; } else { - $try .= "\$y = $class->new('$args[1]');"; + if ($args[1] !~ /\./) + { + $try .= "\$y = $class->new(\"$args[1]\");"; # BigInt + } + else + { + $try .= "\$y = $ECL->new(\"$args[1]\");"; # BigFloat + } if ($f eq "bcmp") { $try .= '$x <=> $y;'; @@ -261,7 +271,7 @@ __DATA__ 100:3:1 8:9:8 &/= -100:3:33 +100:3:33.33333333333333333333333333333333333333 -8:2:-4 &|= 2:1:3 @@ -820,21 +830,23 @@ NaNmul:-inf:NaN 99999999999999999:100000000000000000:9999999999999999900000000000000000 999999999999999999:1000000000000000000:999999999999999999000000000000000000 9999999999999999999:10000000000000000000:99999999999999999990000000000000000000 +3:3.5:10.5^ +3.5:3:10.5^ &bdiv-list 100:20:5,0 4095:4095:1,0 -4095:-4095:1,0 4095:-4095:-1,0 -4095:4095:-1,0 -123:2:61,1 -9:5:1,4 -9:4:2,1 +123:2:61.5,1 +9:5:1.8,4 +9:4:2.25,1 # inf handling and general remainder 5:8:0.625,5 0:8:0,0 -11:2:5,1 -11:-2:-5,-1 --11:2:-5,1 +11:2:5.5,1 +11:-2:-5.5,-1 +-11:2:-5.5,1 # see table in documentation in MBI 0:inf:0,0 0:-inf:0,0 @@ -885,10 +897,10 @@ inf:0:inf -8:0:-inf -inf:0:-inf 0:0:NaN -11:2:5 --11:-2:5 --11:2:-5 -11:-2:-5 +11:2:5.5^ +-11:-2:5.5^ +-11:2:-5.5^ +11:-2:-5.5^ 0:1:0 0:-1:0 1:1:1 @@ -897,19 +909,19 @@ inf:0:inf -1:1:-1 1:2:0.5^ 2:1:2 -1000000000:9:111111111 -2000000000:9:222222222 -3000000000:9:333333333 -4000000000:9:444444444 -5000000000:9:555555555 -6000000000:9:666666666 -7000000000:9:777777777 -8000000000:9:888888888 +1000000000:9:111111111.1111111111111111111111111111111^ +2000000000:9:222222222.2222222222222222222222222222222^ +3000000000:9:333333333.3333333333333333333333333333333^ +4000000000:9:444444444.4444444444444444444444444444444^ +5000000000:9:555555555.5555555555555555555555555555556^ +6000000000:9:666666666.6666666666666666666666666666667^ +7000000000:9:777777777.7777777777777777777777777777778^ +8000000000:9:888888888.8888888888888888888888888888889^ 9000000000:9:1000000000 -35500000:113:314159 -71000000:226:314159 -106500000:339:314159 -1000000000:3:333333333 +35500000:113:314159.2920353982300884955752212389380531^ +71000000:226:314159.2920353982300884955752212389380531^ +106500000:339:314159.2920353982300884955752212389380531^ +1000000000:3:333333333.3333333333333333333333333333333^ +10:+5:2 +100:+4:25 +1000:+8:125 @@ -920,24 +932,22 @@ inf:0:inf 999999999999:9999:100010001 999999999999999:99999:10000100001 +1111088889:99999:11111 --5:-3:1 --5:3:-1 -4:3:1 -4:-3:-1 -1:3:0.3333333333333333333333333333333333333333 -1:-3:-0.3333333333333333333333333333333333333333 --2:-3:0.6666666666666666666666666666666666666667 --2:3:-0.6666666666666666666666666666666666666667 -#8:5:1.6^ -#-8:5:-1.6^ -8:5:1 --8:5:-1 -14:-3:-4 --14:3:-4 --14:-3:4 -14:3:4 +-5:-3:1.666666666666666666666666666666666666667^ +-5:3:-1.666666666666666666666666666666666666667^ +4:3:1.333333333333333333333333333333333333333^ +4:-3:-1.333333333333333333333333333333333333333^ +1:3:0.3333333333333333333333333333333333333333^ +1:-3:-0.3333333333333333333333333333333333333333^ +-2:-3:0.6666666666666666666666666666666666666667^ +-2:3:-0.6666666666666666666666666666666666666667^ +8:5:1.6^ +-8:5:-1.6^ +14:-3:-4.666666666666666666666666666666666666667^ +-14:3:-4.666666666666666666666666666666666666667^ +-14:-3:4.666666666666666666666666666666666666667^ +14:3:4.666666666666666666666666666666666666667^ # bug in Calc with '99999' vs $BASE-1 -10000000000000000000000000000000000000000000000000000000000000000000000000000000000:10000000375084540248994272022843165711074:999999962491547381984643365663244474111576 +#10000000000000000000000000000000000000000000000000000000000000000000000000000000000:10000000375084540248994272022843165711074:999999962491547381984643365663244474111576 12:24:0.5^ &bmod # inf handling, see table in doc @@ -1289,6 +1299,7 @@ abc:12:NaN 10:9:1000000000 10:20:100000000000000000000 123456:2:15241383936 +#2:0.5:1.41^ &length 100:3 10:2 -- 1.8.3.1