Tcl Source Code

Check-in [7442311ee4]
Login
Bounty program for improvements to Tcl and certain Tcl packages.
Tcl 2019 Conference, Houston/TX, US, Nov 4-8
Send your abstracts to [email protected]
or submit via the online form by Sep 9.

Many hyperlinks are disabled.
Use anonymous login to enable hyperlinks.

Overview
Comment:Restore bn_mp_add_d.c to exact copy of libtommath-1.0 version: Since the mp_clamp() function already restores the sign of it's argument to positive if c->used ==0, it is not necessary to do that twice. Therefore, the original version of the code is correct.
Downloads: Tarball | ZIP archive | SQL archive
Timelines: family | ancestors | descendants | both | libtommath-1.0
Files: files | file ages | folders
SHA1: 7442311ee48229d0478a3130e5311e25da322fe0
User & Date: jan.nijtmans 2016-11-17 13:18:17
Context
2016-11-17
15:30
Restore bn_mp_radix_size.c to exact copy of libtommath-1.0 version: Since the radix_size of "9" shou... Closed-Leaf check-in: 8cf7627603 user: jan.nijtmans tags: libtommath-1.0
13:18
Restore bn_mp_add_d.c to exact copy of libtommath-1.0 version: Since the mp_clamp() function already... check-in: 7442311ee4 user: jan.nijtmans tags: libtommath-1.0
11:38
Add test-case for mp_iseven(). If mp_iseven(0) ever returns 0, we will be warned that we are using t... check-in: d3f1169620 user: jan.nijtmans tags: libtommath-1.0
Changes
Hide Diffs Unified Diffs Ignore Whitespace Patch

Changes to libtommath/bn_mp_add_d.c.

33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
  if ((a->sign == MP_NEG) && ((a->used > 1) || (a->dp[0] >= b))) {
     /* temporarily fix sign of a */
     a->sign = MP_ZPOS;

     /* c = |a| - b */
     res = mp_sub_d(a, b, c);

     /* fix signs  */
     a->sign = MP_NEG;
     c->sign = (c->used) ? MP_NEG : MP_ZPOS;

     /* clamp */
     mp_clamp(c);

     return res;
  }







|
|
<







33
34
35
36
37
38
39
40
41

42
43
44
45
46
47
48
  if ((a->sign == MP_NEG) && ((a->used > 1) || (a->dp[0] >= b))) {
     /* temporarily fix sign of a */
     a->sign = MP_ZPOS;

     /* c = |a| - b */
     res = mp_sub_d(a, b, c);

     /* fix sign  */
     a->sign = c->sign = MP_NEG;


     /* clamp */
     mp_clamp(c);

     return res;
  }