add parentheses for explicit operator precedence
This commit is contained in:
parent
b6636ee46a
commit
84db6f9dbc
14
tommath.h
14
tommath.h
@ -25,11 +25,11 @@
|
|||||||
#include <tommath_class.h>
|
#include <tommath_class.h>
|
||||||
|
|
||||||
#ifndef MIN
|
#ifndef MIN
|
||||||
#define MIN(x,y) ((x)<(y)?(x):(y))
|
#define MIN(x,y) (((x) < (y)) ? (x) : (y))
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
#ifndef MAX
|
#ifndef MAX
|
||||||
#define MAX(x,y) ((x)>(y)?(x):(y))
|
#define MAX(x,y) (((x) > (y)) ? (x) : (y))
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
#ifdef __cplusplus
|
#ifdef __cplusplus
|
||||||
@ -200,7 +200,7 @@ extern int KARATSUBA_MUL_CUTOFF,
|
|||||||
#endif
|
#endif
|
||||||
|
|
||||||
/* size of comba arrays, should be at least 2 * 2**(BITS_PER_WORD - BITS_PER_DIGIT*2) */
|
/* size of comba arrays, should be at least 2 * 2**(BITS_PER_WORD - BITS_PER_DIGIT*2) */
|
||||||
#define MP_WARRAY (1 << (sizeof(mp_word) * CHAR_BIT - 2 * DIGIT_BIT + 1))
|
#define MP_WARRAY (1 << ((sizeof(mp_word) * CHAR_BIT) - (2 * DIGIT_BIT) + 1))
|
||||||
|
|
||||||
/* the infamous mp_int structure */
|
/* the infamous mp_int structure */
|
||||||
typedef struct {
|
typedef struct {
|
||||||
@ -246,8 +246,8 @@ int mp_init_size(mp_int *a, int size);
|
|||||||
|
|
||||||
/* ---> Basic Manipulations <--- */
|
/* ---> Basic Manipulations <--- */
|
||||||
#define mp_iszero(a) (((a)->used == 0) ? MP_YES : MP_NO)
|
#define mp_iszero(a) (((a)->used == 0) ? MP_YES : MP_NO)
|
||||||
#define mp_iseven(a) (((a)->used > 0 && (((a)->dp[0] & 1) == 0)) ? MP_YES : MP_NO)
|
#define mp_iseven(a) ((((a)->used > 0) && (((a)->dp[0] & 1) == 0)) ? MP_YES : MP_NO)
|
||||||
#define mp_isodd(a) (((a)->used > 0 && (((a)->dp[0] & 1) == 1)) ? MP_YES : MP_NO)
|
#define mp_isodd(a) ((((a)->used > 0) && (((a)->dp[0] & 1) == 1)) ? MP_YES : MP_NO)
|
||||||
#define mp_isneg(a) (((a)->sign) ? MP_YES : MP_NO)
|
#define mp_isneg(a) (((a)->sign) ? MP_YES : MP_NO)
|
||||||
|
|
||||||
/* set to zero */
|
/* set to zero */
|
||||||
@ -639,14 +639,14 @@ int func_name (mp_int * a, type b) \
|
|||||||
mp_zero (a); \
|
mp_zero (a); \
|
||||||
\
|
\
|
||||||
/* set four bits at a time */ \
|
/* set four bits at a time */ \
|
||||||
for (x = 0; x < sizeof(type) * 2; x++) { \
|
for (x = 0; x < (sizeof(type) * 2); x++) { \
|
||||||
/* shift the number up four bits */ \
|
/* shift the number up four bits */ \
|
||||||
if ((res = mp_mul_2d (a, 4, a)) != MP_OKAY) { \
|
if ((res = mp_mul_2d (a, 4, a)) != MP_OKAY) { \
|
||||||
return res; \
|
return res; \
|
||||||
} \
|
} \
|
||||||
\
|
\
|
||||||
/* OR in the top four bits of the source */ \
|
/* OR in the top four bits of the source */ \
|
||||||
a->dp[0] |= (b >> ((sizeof(type)) * 8 - 4)) & 15; \
|
a->dp[0] |= (b >> ((sizeof(type) * 8) - 4)) & 15; \
|
||||||
\
|
\
|
||||||
/* shift the source up to the next four bits */ \
|
/* shift the source up to the next four bits */ \
|
||||||
b <<= 4; \
|
b <<= 4; \
|
||||||
|
Loading…
Reference in New Issue
Block a user