Skip to content

Commit c61d215

Browse files
committed
corrected comments
1 parent ca42e67 commit c61d215

File tree

1 file changed

+10
-11
lines changed

1 file changed

+10
-11
lines changed

bn_mp_n_root_ex.c

Lines changed: 10 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -19,8 +19,7 @@
1919
* This algorithm uses Newton's approximation
2020
* x[i+1] = x[i] - f(x[i])/f'(x[i])
2121
* which will find the root in log(N) time where
22-
* each step involves a fair bit. This is not meant to
23-
* find huge roots [square and cube, etc].
22+
* each step involves a fair bit.
2423
*/
2524
int mp_n_root_ex(const mp_int *a, mp_digit b, mp_int *c, int fast)
2625
{
@@ -52,13 +51,13 @@ int mp_n_root_ex(const mp_int *a, mp_digit b, mp_int *c, int fast)
5251
/* Compute seed: 2^(log_2(n)/b + 2)*/
5352
ilog2 = mp_count_bits(a);
5453

55-
/*
56-
GCC and clang do not understand the sizeof tests and complain,
57-
icc (the Intel compiler) seems to understand, at least it doesn't complain.
58-
2 of 3 say these macros are necessary, so there they are.
59-
*/
54+
/*
55+
GCC and clang do not understand the sizeof tests and complain,
56+
icc (the Intel compiler) seems to understand, at least it doesn't complain.
57+
2 of 3 say these macros are necessary, so there they are.
58+
*/
6059
#if ( !(defined MP_8BIT) && !(defined MP_16BIT) )
61-
/*
60+
/*
6261
The type of mp_digit might be larger than an int.
6362
If "b" is larger than INT_MAX it is also larger than
6463
log_2(n) because the bit-length of the "n" is measured
@@ -89,7 +88,7 @@ int mp_n_root_ex(const mp_int *a, mp_digit b, mp_int *c, int fast)
8988
}
9089
/* Start value must be larger than root */
9190
ilog2 += 2;
92-
if (( res = mp_2expt(&t2,ilog2)) != MP_OKAY) {
91+
if ((res = mp_2expt(&t2,ilog2)) != MP_OKAY) {
9392
goto LBL_T3;
9493
}
9594
do {
@@ -129,7 +128,7 @@ int mp_n_root_ex(const mp_int *a, mp_digit b, mp_int *c, int fast)
129128
if ((res = mp_sub(&t1, &t3, &t2)) != MP_OKAY) {
130129
goto LBL_T3;
131130
}
132-
/*
131+
/*
133132
Number of rounds is at most log_2(root). If it is more it
134133
got stuck, so break out of the loop and do the rest manually.
135134
*/
@@ -139,7 +138,7 @@ int mp_n_root_ex(const mp_int *a, mp_digit b, mp_int *c, int fast)
139138
} while (mp_cmp(&t1, &t2) != MP_EQ);
140139

141140
/* result can be off by a few so check */
142-
/* Overshoot by one if root is smaller */
141+
/* Loop beneath can overshoot by one if found root is smaller than actual root */
143142
for (;;) {
144143
if ((res = mp_expt_d_ex(&t1, b, &t2, fast)) != MP_OKAY) {
145144
goto LBL_T3;

0 commit comments

Comments
 (0)