diff options
author | jan.nijtmans <nijtmans@users.sourceforge.net> | 2019-03-27 20:21:58 (GMT) |
---|---|---|
committer | jan.nijtmans <nijtmans@users.sourceforge.net> | 2019-03-27 20:21:58 (GMT) |
commit | e30b6432e181ac33887f4fcf3c2fcdfbbfceba78 (patch) | |
tree | eea77fa0fe0cb5a14eb9d1c84a802c3e10446b87 | |
parent | 40c2f59cf46d093eede7b2846be0e3a7d9b3eeaa (diff) | |
parent | d74f47cb2ad9e4fa4b038c1a2205f3e8becc2af0 (diff) | |
download | tcl-e30b6432e181ac33887f4fcf3c2fcdfbbfceba78.zip tcl-e30b6432e181ac33887f4fcf3c2fcdfbbfceba78.tar.gz tcl-e30b6432e181ac33887f4fcf3c2fcdfbbfceba78.tar.bz2 |
Merge 8.6
-rw-r--r-- | .fossil-settings/ignore-glob | 2 | ||||
-rw-r--r-- | doc/expr.n | 3 | ||||
-rw-r--r-- | doc/mathop.n | 9 | ||||
-rw-r--r-- | generic/tclExecute.c | 6 | ||||
-rw-r--r-- | generic/tclTomMath.h | 4 | ||||
-rw-r--r-- | libtommath/tommath.h | 4 | ||||
-rw-r--r-- | tests/expr.test | 42 |
7 files changed, 39 insertions, 31 deletions
diff --git a/.fossil-settings/ignore-glob b/.fossil-settings/ignore-glob index 9bfacde..cd6e689 100644 --- a/.fossil-settings/ignore-glob +++ b/.fossil-settings/ignore-glob @@ -26,9 +26,11 @@ libtommath/bn.ilg libtommath/bn.ind libtommath/pretty.build libtommath/tommath.src +libtommath/*.log libtommath/*.pdf libtommath/*.pl libtommath/*.sh +libtommath/doc/* libtommath/tombc/* libtommath/pre_gen/* libtommath/pics/* @@ -126,7 +126,8 @@ applied to integers. .TP 20 \fB**\fR . -Exponentiation. Valid for numeric operands. +Exponentiation. Valid for numeric operands. The maximum exponent value +that Tcl can handle if the first number is an integer > 1 is 268435455. .TP 20 \fB*\0\0/\0\0%\fR . diff --git a/doc/mathop.n b/doc/mathop.n index 4c16d76..84cf308 100644 --- a/doc/mathop.n +++ b/doc/mathop.n @@ -151,10 +151,11 @@ is the same as .QW "\fB** 2 [** 3 4]\fR" . Each \fInumber\fR may be any numeric value, though the second number must not be fractional if the -first is negative. If no arguments are given, the result will be one, and if -only one argument is given, the result will be that argument. The -result will have an integral value only when all arguments are -integral values. +first is negative. The maximum exponent value that Tcl can handle if the +first number is an integer > 1 is 268435455. If no arguments are given, +the result will be one, and if only one argument is given, the result will +be that argument. The result will have an integral value only when all +arguments are integral values. .SS "COMPARISON OPERATORS" .PP The behaviors of the comparison operator commands (most of which operate diff --git a/generic/tclExecute.c b/generic/tclExecute.c index 618ba83..680bdd0 100644 --- a/generic/tclExecute.c +++ b/generic/tclExecute.c @@ -8400,7 +8400,11 @@ ExecuteExtendedBinaryMathOp( overflowExpon: Tcl_TakeBignumFromObj(NULL, value2Ptr, &big2); - if ((big2.used > 1) || (big2.used == 1 && big2.dp[0] > (1<<28))) { + if ((big2.used > 1) +#if DIGIT_BIT > 28 + || ((big2.used == 1) && (big2.dp[0] >= (1<<28))) +#endif + ) { mp_clear(&big2); Tcl_SetObjResult(interp, Tcl_NewStringObj( "exponent too large", -1)); diff --git a/generic/tclTomMath.h b/generic/tclTomMath.h index fbf0d35..0541ad8 100644 --- a/generic/tclTomMath.h +++ b/generic/tclTomMath.h @@ -229,8 +229,8 @@ int mp_init_size(mp_int *a, int size); /* ---> Basic Manipulations <--- */ #define mp_iszero(a) (((a)->used == 0) ? MP_YES : MP_NO) -#define mp_iseven(a) ((((a)->used == 0) || (((a)->dp[0] & 1u) == 0u)) ? MP_YES : MP_NO) -#define mp_isodd(a) ((((a)->used > 0) && (((a)->dp[0] & 1u) == 1u)) ? MP_YES : MP_NO) +#define mp_iseven(a) (!mp_get_bit((a),0)) +#define mp_isodd(a) mp_get_bit((a),0) #define mp_isneg(a) (((a)->sign != MP_ZPOS) ? MP_YES : MP_NO) /* set to zero */ diff --git a/libtommath/tommath.h b/libtommath/tommath.h index ce38975..236d3e5 100644 --- a/libtommath/tommath.h +++ b/libtommath/tommath.h @@ -192,8 +192,8 @@ int mp_init_size(mp_int *a, int size); /* ---> Basic Manipulations <--- */ #define mp_iszero(a) (((a)->used == 0) ? MP_YES : MP_NO) -#define mp_iseven(a) ((((a)->used == 0) || (((a)->dp[0] & 1u) == 0u)) ? MP_YES : MP_NO) -#define mp_isodd(a) ((((a)->used > 0) && (((a)->dp[0] & 1u) == 1u)) ? MP_YES : MP_NO) +#define mp_iseven(a) (!mp_get_bit((a),0)) +#define mp_isodd(a) mp_get_bit((a),0) #define mp_isneg(a) (((a)->sign != MP_ZPOS) ? MP_YES : MP_NO) /* set to zero */ diff --git a/tests/expr.test b/tests/expr.test index 7136afc..cb0c24d 100644 --- a/tests/expr.test +++ b/tests/expr.test @@ -1107,7 +1107,7 @@ test expr-23.54.11 {INST_EXPON: Bug 2798543} { expr {3**9 == 3**131081} } 0 test expr-23.54.12 {INST_EXPON: Bug 2798543} -body { - expr {3**9 == 3**268435465} + expr {3**268435456} } -returnCodes error -result {exponent too large} test expr-23.54.13 {INST_EXPON: Bug 2798543} { expr {(-3)**9 == (-3)**65545} @@ -1122,7 +1122,7 @@ test expr-23.55.2 {INST_EXPON: Bug 2798543} { expr {4**9 == 4**131081} } 0 test expr-23.55.3 {INST_EXPON: Bug 2798543} -body { - expr {4**9 == 4**268435465} + expr {4**268435456} } -returnCodes error -result {exponent too large} test expr-23.55.4 {INST_EXPON: Bug 2798543} { expr {(-4)**9 == (-4)**65545} @@ -1137,7 +1137,7 @@ test expr-23.56.2 {INST_EXPON: Bug 2798543} { expr {5**9 == 5**131081} } 0 test expr-23.56.3 {INST_EXPON: Bug 2798543} -body { - expr {5**9 == 5**268435465} + expr {5**268435456} } -returnCodes error -result {exponent too large} test expr-23.56.4 {INST_EXPON: Bug 2798543} { expr {(-5)**9 == (-5)**65545} @@ -1152,7 +1152,7 @@ test expr-23.57.2 {INST_EXPON: Bug 2798543} { expr {6**9 == 6**131081} } 0 test expr-23.57.3 {INST_EXPON: Bug 2798543} -body { - expr {6**9 == 6**268435465} + expr {6**268435456} } -returnCodes error -result {exponent too large} test expr-23.57.4 {INST_EXPON: Bug 2798543} { expr {(-6)**9 == (-6)**65545} @@ -1167,7 +1167,7 @@ test expr-23.58.2 {INST_EXPON: Bug 2798543} { expr {7**9 == 7**131081} } 0 test expr-23.58.3 {INST_EXPON: Bug 2798543} -body { - expr {7**9 == 7**268435465} + expr {7**268435456} } -returnCodes error -result {exponent too large} test expr-23.58.4 {INST_EXPON: Bug 2798543} { expr {(-7)**9 == (-7)**65545} @@ -1182,7 +1182,7 @@ test expr-23.59.2 {INST_EXPON: Bug 2798543} { expr {8**9 == 8**131081} } 0 test expr-23.59.3 {INST_EXPON: Bug 2798543} -body { - expr {8**9 == 8**268435465} + expr {8**268435456} } -returnCodes error -result {exponent too large} test expr-23.59.4 {INST_EXPON: Bug 2798543} { expr {(-8)**9 == (-8)**65545} @@ -1194,7 +1194,7 @@ test expr-23.60.1 {INST_EXPON: Bug 2798543} { expr {9**9 == 9**131081} } 0 test expr-23.60.2 {INST_EXPON: Bug 2798543} -body { - expr {9**9 == 9**268435465} + expr {9**268435456} } -returnCodes error -result {exponent too large} test expr-23.60.3 {INST_EXPON: Bug 2798543} { expr {(-9)**9 == (-9)**65545} @@ -1206,7 +1206,7 @@ test expr-23.61.1 {INST_EXPON: Bug 2798543} { expr {10**9 == 10**131081} } 0 test expr-23.61.2 {INST_EXPON: Bug 2798543} -body { - expr {10**9 == 10**268435465} + expr {10**268435456} } -returnCodes error -result {exponent too large} test expr-23.61.3 {INST_EXPON: Bug 2798543} { expr {(-10)**9 == (-10)**65545} @@ -1218,7 +1218,7 @@ test expr-23.62.1 {INST_EXPON: Bug 2798543} { expr {11**9 == 11**131081} } 0 test expr-23.62.2 {INST_EXPON: Bug 2798543} -body { - expr {11**9 == 11**268435465} + expr {11**268435456} } -returnCodes error -result {exponent too large} test expr-23.62.3 {INST_EXPON: Bug 2798543} { expr {(-11)**9 == (-11)**65545} @@ -1233,7 +1233,7 @@ test expr-23.63.2 {INST_EXPON: Bug 2798543} { expr {3**20 == 3**131092} } 0 test expr-23.63.3 {INST_EXPON: Bug 2798543} -body { - expr {3**20 == 3**268435476} + expr {3**268435456} } -returnCodes error -result {exponent too large} test expr-23.63.4 {INST_EXPON: Bug 2798543} { expr {(-3)**20 == (-3)**65556} @@ -1248,7 +1248,7 @@ test expr-23.64.2 {INST_EXPON: Bug 2798543} { expr {4**17 == 4**131089} } 0 test expr-23.64.3 {INST_EXPON: Bug 2798543} -body { - expr {4**17 == 4**268435473} + expr {4**268435456} } -returnCodes error -result {exponent too large} test expr-23.64.4 {INST_EXPON: Bug 2798543} { expr {(-4)**17 == (-4)**65553} @@ -1263,7 +1263,7 @@ test expr-23.65.2 {INST_EXPON: Bug 2798543} { expr {5**17 == 5**131089} } 0 test expr-23.65.3 {INST_EXPON: Bug 2798543} -body { - expr {5**17 == 5**268435473} + expr {5**268435456} } -returnCodes error -result {exponent too large} test expr-23.65.4 {INST_EXPON: Bug 2798543} { expr {(-5)**17 == (-5)**65553} @@ -1278,7 +1278,7 @@ test expr-23.66.2 {INST_EXPON: Bug 2798543} { expr {6**17 == 6**131089} } 0 test expr-23.66.3 {INST_EXPON: Bug 2798543} -body { - expr {6**17 == 6**268435473} + expr {6**268435456} } -returnCodes error -result {exponent too large} test expr-23.66.4 {INST_EXPON: Bug 2798543} { expr {(-6)**17 == (-6)**65553} @@ -1293,7 +1293,7 @@ test expr-23.67.2 {INST_EXPON: Bug 2798543} { expr {7**17 == 7**131089} } 0 test expr-23.67.3 {INST_EXPON: Bug 2798543} -body { - expr {7**17 == 7**268435473} + expr {7**268435456} } -returnCodes error -result {exponent too large} test expr-23.67.4 {INST_EXPON: Bug 2798543} { expr {(-7)**17 == (-7)**65553} @@ -1308,7 +1308,7 @@ test expr-23.68.2 {INST_EXPON: Bug 2798543} { expr {8**17 == 8**131089} } 0 test expr-23.68.3 {INST_EXPON: Bug 2798543} -body { - expr {8**17 == 8**268435473} + expr {8**268435456} } -returnCodes error -result {exponent too large} test expr-23.68.4 {INST_EXPON: Bug 2798543} { expr {(-8)**17 == (-8)**65553} @@ -1323,7 +1323,7 @@ test expr-23.69.2 {INST_EXPON: Bug 2798543} { expr {9**17 == 9**131089} } 0 test expr-23.69.3 {INST_EXPON: Bug 2798543} -body { - expr {9**17 == 9**268435473} + expr {9**268435456} } -returnCodes error -result {exponent too large} test expr-23.69.4 {INST_EXPON: Bug 2798543} { expr {(-9)**17 == (-9)**65553} @@ -1338,7 +1338,7 @@ test expr-23.70.2 {INST_EXPON: Bug 2798543} { expr {10**17 == 10**131089} } 0 test expr-23.70.3 {INST_EXPON: Bug 2798543} -body { - expr {10**17 == 10**268435473} + expr {10**268435456} } -returnCodes error -result {exponent too large} test expr-23.70.4 {INST_EXPON: Bug 2798543} { expr {(-10)**17 == (-10)**65553} @@ -1353,7 +1353,7 @@ test expr-23.71.2 {INST_EXPON: Bug 2798543} { expr {11**17 == 11**131089} } 0 test expr-23.71.3 {INST_EXPON: Bug 2798543} -body { - expr {11**17 == 11**268435473} + expr {11**268435456} } -returnCodes error -result {exponent too large} test expr-23.71.4 {INST_EXPON: Bug 2798543} { expr {(-11)**17 == (-11)**65553} @@ -1365,7 +1365,7 @@ test expr-23.72.1 {INST_EXPON: Bug 2798543} { expr {12**17 == 12**131089} } 0 test expr-23.72.2 {INST_EXPON: Bug 2798543} -body { - expr {12**17 == 12**268435473} + expr {12**268435456} } -returnCodes error -result {exponent too large} test expr-23.72.3 {INST_EXPON: Bug 2798543} { expr {(-12)**17 == (-12)**65553} @@ -1377,7 +1377,7 @@ test expr-23.73.1 {INST_EXPON: Bug 2798543} { expr {13**17 == 13**131089} } 0 test expr-23.73.2 {INST_EXPON: Bug 2798543} -body { - expr {13**17 == 13**268435473} + expr {13**268435456} } -returnCodes error -result {exponent too large} test expr-23.73.3 {INST_EXPON: Bug 2798543} { expr {(-13)**17 == (-13)**65553} @@ -1389,7 +1389,7 @@ test expr-23.74.1 {INST_EXPON: Bug 2798543} { expr {14**17 == 14**131089} } 0 test expr-23.74.2 {INST_EXPON: Bug 2798543} -body { - expr {14**17 == 14**268435473} + expr {14**268435456} } -returnCodes error -result {exponent too large} test expr-23.74.3 {INST_EXPON: Bug 2798543} { expr {(-14)**17 == (-14)**65553} |