explicit precedence operator with parenthesis

This commit is contained in:
Francois Perrad 2017-12-10 10:19:11 +01:00
parent f5876db051
commit 0dbea3b69f
5 changed files with 9 additions and 9 deletions

View File

@ -746,7 +746,7 @@ printf("compare no compare!\n"); return EXIT_FAILURE;
mp_div_2d(&a, rr, &a, &e); mp_div_2d(&a, rr, &a, &e);
a.sign = b.sign; a.sign = b.sign;
if (a.used == b.used && a.used == 0) { if ((a.used == b.used) && (a.used == 0)) {
a.sign = b.sign = MP_ZPOS; a.sign = b.sign = MP_ZPOS;
} }
if (mp_cmp(&a, &b) != MP_EQ) { if (mp_cmp(&a, &b) != MP_EQ) {
@ -847,7 +847,7 @@ printf("compare no compare!\n"); return EXIT_FAILURE;
mp_read_radix(&d, buf, 64); mp_read_radix(&d, buf, 64);
mp_div(&a, &b, &e, &f); mp_div(&a, &b, &e, &f);
if (mp_cmp(&c, &e) != MP_EQ || mp_cmp(&d, &f) != MP_EQ) { if ((mp_cmp(&c, &e) != MP_EQ) || (mp_cmp(&d, &f) != MP_EQ)) {
printf("div %lu %d, %d, failure!\n", div_n, mp_cmp(&c, &e), printf("div %lu %d, %d, failure!\n", div_n, mp_cmp(&c, &e),
mp_cmp(&d, &f)); mp_cmp(&d, &f));
draw(&a); draw(&a);

View File

@ -179,7 +179,7 @@ int main(void)
TOOM_SQR_CUTOFF = (ix == 2) ? old_toom_s : 9999; TOOM_SQR_CUTOFF = (ix == 2) ? old_toom_s : 9999;
log = FOPEN((ix == 0) ? "logs/mult.log" : (ix == 1) ? "logs/mult_kara.log" : "logs/mult_toom.log", "w"); log = FOPEN((ix == 0) ? "logs/mult.log" : (ix == 1) ? "logs/mult_kara.log" : "logs/mult_toom.log", "w");
for (cnt = 4; cnt <= 10240 / DIGIT_BIT; cnt += 2) { for (cnt = 4; cnt <= (10240 / DIGIT_BIT); cnt += 2) {
SLEEP; SLEEP;
mp_rand(&a, cnt); mp_rand(&a, cnt);
mp_rand(&b, cnt); mp_rand(&b, cnt);
@ -200,7 +200,7 @@ int main(void)
FCLOSE(log); FCLOSE(log);
log = FOPEN((ix == 0) ? "logs/sqr.log" : (ix == 1) ? "logs/sqr_kara.log" : "logs/sqr_toom.log", "w"); log = FOPEN((ix == 0) ? "logs/sqr.log" : (ix == 1) ? "logs/sqr_kara.log" : "logs/sqr_toom.log", "w");
for (cnt = 4; cnt <= 10240 / DIGIT_BIT; cnt += 2) { for (cnt = 4; cnt <= (10240 / DIGIT_BIT); cnt += 2) {
SLEEP; SLEEP;
mp_rand(&a, cnt); mp_rand(&a, cnt);
rr = 0; rr = 0;
@ -290,7 +290,7 @@ int main(void)
} }
printf("Exponentiating\t%4d-bit => %9" PRIu64 "/sec, %9" PRIu64 " cycles\n", printf("Exponentiating\t%4d-bit => %9" PRIu64 "/sec, %9" PRIu64 " cycles\n",
mp_count_bits(&a), CLK_PER_SEC / tt, tt); mp_count_bits(&a), CLK_PER_SEC / tt, tt);
FPRINTF(n < 4 ? logd : (n < 9) ? logc : (n < 16) ? logb : log, FPRINTF((n < 4) ? logd : (n < 9) ? logc : (n < 16) ? logb : log,
"%d %9" PRIu64 "\n", mp_count_bits(&a), tt); "%d %9" PRIu64 "\n", mp_count_bits(&a), tt);
} }
} }

View File

@ -32,7 +32,7 @@ top:
break; break;
} }
if (clock() - t1 > CLOCKS_PER_SEC) { if ((clock() - t1) > CLOCKS_PER_SEC) {
printf("."); printf(".");
fflush(stdout); fflush(stdout);
// sleep((clock() - t1 + CLOCKS_PER_SEC/2)/CLOCKS_PER_SEC); // sleep((clock() - t1 + CLOCKS_PER_SEC/2)/CLOCKS_PER_SEC);

View File

@ -32,7 +32,7 @@ static int is_mersenne(long s, int *pp)
mp_set(&u, 4); mp_set(&u, 4);
/* for k=1 to s-2 do */ /* for k=1 to s-2 do */
for (k = 1; k <= s - 2; k++) { for (k = 1; k <= (s - 2); k++) {
/* u = u^2 - 2 mod n */ /* u = u^2 - 2 mod n */
if ((res = mp_sqr(&u, &u)) != MP_OKAY) { if ((res = mp_sqr(&u, &u)) != MP_OKAY) {
goto LBL_MU; goto LBL_MU;
@ -79,7 +79,7 @@ static long i_sqrt(long x)
x2 = x1 - ((x1 * x1) - x) / (2 * x1); x2 = x1 - ((x1 * x1) - x) / (2 * x1);
} while (x1 != x2); } while (x1 != x2);
if (x1 * x1 > x) { if ((x1 * x1) > x) {
--x1; --x1;
} }

View File

@ -21,7 +21,7 @@ static mp_digit i_sqrt(mp_word x)
x2 = x1 - ((x1 * x1) - x) / (2 * x1); x2 = x1 - ((x1 * x1) - x) / (2 * x1);
} while (x1 != x2); } while (x1 != x2);
if (x1 * x1 > x) { if ((x1 * x1) > x) {
--x1; --x1;
} }