summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorjan.nijtmans <nijtmans@users.sourceforge.net>2018-02-27 20:48:00 (GMT)
committerjan.nijtmans <nijtmans@users.sourceforge.net>2018-02-27 20:48:00 (GMT)
commit9a809e614ae7603730d8cc5f60b454b66dffa972 (patch)
tree4df7f67a7ff3133e363a264c3610852fb46d9f4d
parent0bceead396460bd96a148e6a6c9e55acc1ed7311 (diff)
downloadtcl-9a809e614ae7603730d8cc5f60b454b66dffa972.zip
tcl-9a809e614ae7603730d8cc5f60b454b66dffa972.tar.gz
tcl-9a809e614ae7603730d8cc5f60b454b66dffa972.tar.bz2
Use mp_isneg() in stead of mp_cmp_d() when the output of this function is simply compared with MP_LT.
-rw-r--r--generic/tclBasic.c2
-rw-r--r--generic/tclExecute.c18
-rw-r--r--generic/tclScan.c2
-rw-r--r--generic/tclStrToD.c4
4 files changed, 13 insertions, 13 deletions
diff --git a/generic/tclBasic.c b/generic/tclBasic.c
index a182139..3d16b70 100644
--- a/generic/tclBasic.c
+++ b/generic/tclBasic.c
@@ -7527,7 +7527,7 @@ ExprAbsFunc(
}
if (type == TCL_NUMBER_BIG) {
- if (mp_cmp_d((const mp_int *) ptr, 0) == MP_LT) {
+ if (mp_isneg((const mp_int *) ptr)) {
Tcl_GetBignumFromObj(NULL, objv[1], &big);
tooLarge:
mp_neg(&big, &big);
diff --git a/generic/tclExecute.c b/generic/tclExecute.c
index a83023c..1c69474 100644
--- a/generic/tclExecute.c
+++ b/generic/tclExecute.c
@@ -8092,7 +8092,7 @@ ExecuteExtendedBinaryMathOp(
break;
case TCL_NUMBER_BIG:
Tcl_TakeBignumFromObj(NULL, value2Ptr, &big2);
- invalid = (mp_cmp_d(&big2, 0) == MP_LT);
+ invalid = mp_isneg(&big2);
mp_clear(&big2);
break;
default:
@@ -8171,7 +8171,7 @@ ExecuteExtendedBinaryMathOp(
break;
case TCL_NUMBER_BIG:
Tcl_TakeBignumFromObj(NULL, valuePtr, &big1);
- zero = (mp_cmp_d(&big1, 0) == MP_GT);
+ zero = (!mp_isneg(&big1));
mp_clear(&big1);
break;
default:
@@ -8209,7 +8209,7 @@ ExecuteExtendedBinaryMathOp(
} else {
mp_init(&bigRemainder);
mp_div_2d(&big1, shift, &bigResult, &bigRemainder);
- if (mp_cmp_d(&bigRemainder, 0) == MP_LT) {
+ if (mp_isneg(&bigRemainder)) {
/*
* Convert to Tcl's integer division rules.
*/
@@ -8236,14 +8236,14 @@ ExecuteExtendedBinaryMathOp(
* arguments is negative, store it in 'Second'.
*/
- if (mp_cmp_d(&big1, 0) != MP_LT) {
- numPos = 1 + (mp_cmp_d(&big2, 0) != MP_LT);
+ if (!mp_isneg(&big1)) {
+ numPos = 1 + !mp_isneg(&big2);
First = &big1;
Second = &big2;
} else {
First = &big2;
Second = &big1;
- numPos = (mp_cmp_d(First, 0) != MP_LT);
+ numPos = (!mp_isneg(First));
}
mp_init(&bigResult);
@@ -8445,7 +8445,7 @@ ExecuteExtendedBinaryMathOp(
break;
case TCL_NUMBER_BIG:
Tcl_TakeBignumFromObj(NULL, value2Ptr, &big2);
- negativeExponent = (mp_cmp_d(&big2, 0) == MP_LT);
+ negativeExponent = mp_isneg(&big2);
mp_mod_2d(&big2, 1, &big2);
oddExponent = !mp_iszero(&big2);
mp_clear(&big2);
@@ -8995,7 +8995,7 @@ TclCompareTwoNumbers(
goto wideCompare;
case TCL_NUMBER_BIG:
Tcl_TakeBignumFromObj(NULL, value2Ptr, &big2);
- if (mp_cmp_d(&big2, 0) == MP_LT) {
+ if (mp_isneg(&big2)) {
compare = MP_GT;
} else {
compare = MP_LT;
@@ -9032,7 +9032,7 @@ TclCompareTwoNumbers(
}
Tcl_TakeBignumFromObj(NULL, value2Ptr, &big2);
if ((d1 < (double)LONG_MAX) && (d1 > (double)LONG_MIN)) {
- if (mp_cmp_d(&big2, 0) == MP_LT) {
+ if (mp_isneg(&big2)) {
compare = MP_GT;
} else {
compare = MP_LT;
diff --git a/generic/tclScan.c b/generic/tclScan.c
index 25c6c2b..d55d29b 100644
--- a/generic/tclScan.c
+++ b/generic/tclScan.c
@@ -942,7 +942,7 @@ Tcl_ScanObjCmd(
if (flags & SCAN_UNSIGNED) {
mp_int big;
if ((Tcl_GetBignumFromObj(interp, objPtr, &big) != TCL_OK)
- || (mp_cmp_d(&big, 0) == MP_LT)) {
+ || mp_isneg(&big)) {
Tcl_SetObjResult(interp, Tcl_NewStringObj(
"unsigned bignum scans are invalid", -1));
Tcl_SetErrorCode(interp, "TCL", "FORMAT", "BADUNSIGNED",NULL);
diff --git a/generic/tclStrToD.c b/generic/tclStrToD.c
index ac2ca68..0434919 100644
--- a/generic/tclStrToD.c
+++ b/generic/tclStrToD.c
@@ -4697,7 +4697,7 @@ TclCeil(
mp_int b;
mp_init(&b);
- if (mp_cmp_d(a, 0) == MP_LT) {
+ if (mp_isneg(a)) {
mp_neg(a, &b);
r = -TclFloor(&b);
} else {
@@ -4754,7 +4754,7 @@ TclFloor(
mp_int b;
mp_init(&b);
- if (mp_cmp_d(a, 0) == MP_LT) {
+ if (mp_isneg(a)) {
mp_neg(a, &b);
r = -TclCeil(&b);
} else {