diff options
author | jan.nijtmans <nijtmans@users.sourceforge.net> | 2019-03-15 20:52:25 (GMT) |
---|---|---|
committer | jan.nijtmans <nijtmans@users.sourceforge.net> | 2019-03-15 20:52:25 (GMT) |
commit | 2ff70c01f60ef1dbb586489d97b1f36368ad6741 (patch) | |
tree | 818e1ae3cdf91deda3a567394b28a643beebaba6 /generic/tclStrToD.c | |
parent | d7fe4af6212051638be9eb9f6912e844e51fb22c (diff) | |
download | tcl-2ff70c01f60ef1dbb586489d97b1f36368ad6741.zip tcl-2ff70c01f60ef1dbb586489d97b1f36368ad6741.tar.gz tcl-2ff70c01f60ef1dbb586489d97b1f36368ad6741.tar.bz2 |
Eliminate usage of mp_isneg(), just check bignum->sign directly (as libtommath itself does)
Make TclInitBugnumFromLong() a static function in stubtable only, as it isn't used by Tcl anymore.
Diffstat (limited to 'generic/tclStrToD.c')
-rw-r--r-- | generic/tclStrToD.c | 16 |
1 files changed, 8 insertions, 8 deletions
diff --git a/generic/tclStrToD.c b/generic/tclStrToD.c index b7f35e6..e7cb2c5 100644 --- a/generic/tclStrToD.c +++ b/generic/tclStrToD.c @@ -530,7 +530,7 @@ TclParseNumber( int shift = 0; /* Amount to shift when accumulating binary */ int explicitOctal = 0; -#define ALL_BITS (~(Tcl_WideUInt)0) +#define ALL_BITS ((Tcl_WideUInt)-1) #define MOST_BITS (ALL_BITS >> 1) /* @@ -709,7 +709,7 @@ TclParseNumber( && (((size_t)shift >= CHAR_BIT*sizeof(Tcl_WideUInt)) || (octalSignificandWide > - (~(Tcl_WideUInt)0 >> shift)))) { + ((Tcl_WideUInt)-1 >> shift)))) { octalSignificandOverflow = 1; TclInitBignumFromWideUInt(&octalSignificandBig, octalSignificandWide); @@ -826,7 +826,7 @@ TclParseNumber( if (significandWide != 0 && ((size_t)shift >= CHAR_BIT*sizeof(Tcl_WideUInt) || - significandWide > (~(Tcl_WideUInt)0 >> shift))) { + significandWide > ((Tcl_WideUInt)-1 >> shift))) { significandOverflow = 1; TclInitBignumFromWideUInt(&significandBig, significandWide); @@ -867,7 +867,7 @@ TclParseNumber( if (significandWide != 0 && ((size_t)shift >= CHAR_BIT*sizeof(Tcl_WideUInt) || - significandWide > (~(Tcl_WideUInt)0 >> shift))) { + significandWide > ((Tcl_WideUInt)-1 >> shift))) { significandOverflow = 1; TclInitBignumFromWideUInt(&significandBig, significandWide); @@ -1451,7 +1451,7 @@ AccumulateDecimalDigit( *wideRepPtr = digit; return 0; } else if (numZeros >= maxpow10_wide - || w > ((~(Tcl_WideUInt)0)-digit)/pow10_wide[numZeros+1]) { + || w > ((Tcl_WideUInt)-1-digit)/pow10_wide[numZeros+1]) { /* * Wide multiplication will overflow. Expand the number to a * bignum and fall through into the bignum case. @@ -4649,7 +4649,7 @@ TclCeil( mp_int b; mp_init(&b); - if (mp_isneg(a)) { + if (a->sign != MP_ZPOS) { mp_neg(a, &b); r = -TclFloor(&b); } else { @@ -4666,7 +4666,7 @@ TclCeil( mp_int d; mp_init(&d); mp_div_2d(a, -shift, &b, &d); - exact = mp_iszero(&d); + exact = d.used == 0; mp_clear(&d); } else { mp_copy(a, &b); @@ -4706,7 +4706,7 @@ TclFloor( mp_int b; mp_init(&b); - if (mp_isneg(a)) { + if (a->sign != MP_ZPOS) { mp_neg(a, &b); r = -TclCeil(&b); } else { |