refactor literal suffix with u lowercase

This commit is contained in:
Francois Perrad 2019-05-19 16:36:53 +02:00
parent fd68b6526c
commit 150c47cce2
5 changed files with 7 additions and 7 deletions

View File

@ -7,6 +7,6 @@
unsigned long mp_get_int(const mp_int *a) unsigned long mp_get_int(const mp_int *a)
{ {
/* force result to 32-bits always so it is consistent on non 32-bit platforms */ /* force result to 32-bits always so it is consistent on non 32-bit platforms */
return mp_get_long(a) & 0xFFFFFFFFUL; return mp_get_long(a) & 0xFFFFFFFFuL;
} }
#endif #endif

View File

@ -19,7 +19,7 @@ unsigned long mp_get_long(const mp_int *a)
/* get most significant digit of result */ /* get most significant digit of result */
res = (unsigned long)a->dp[i]; res = (unsigned long)a->dp[i];
#if (ULONG_MAX != 0xFFFFFFFFUL) || (MP_DIGIT_BIT < 32) #if (ULONG_MAX != 0xFFFFFFFFuL) || (MP_DIGIT_BIT < 32)
while (--i >= 0) { while (--i >= 0) {
res = (res << MP_DIGIT_BIT) | (unsigned long)a->dp[i]; res = (res << MP_DIGIT_BIT) | (unsigned long)a->dp[i];
} }

View File

@ -15,8 +15,8 @@ mp_err mp_set_double(mp_int *a, double b)
} cast; } cast;
cast.dbl = b; cast.dbl = b;
exp = (int)((unsigned)(cast.bits >> 52) & 0x7FFU); exp = (int)((unsigned)(cast.bits >> 52) & 0x7FFu);
frac = (cast.bits & ((1ULL << 52) - 1ULL)) | (1ULL << 52); frac = (cast.bits & ((1uLL << 52) - 1uLL)) | (1uLL << 52);
if (exp == 0x7FF) { /* +-inf, NaN */ if (exp == 0x7FF) { /* +-inf, NaN */
return MP_VAL; return MP_VAL;
@ -30,7 +30,7 @@ mp_err mp_set_double(mp_int *a, double b)
return err; return err;
} }
if (((cast.bits >> 63) != 0ULL) && !MP_IS_ZERO(a)) { if (((cast.bits >> 63) != 0uLL) && !MP_IS_ZERO(a)) {
a->sign = MP_NEG; a->sign = MP_NEG;
} }

View File

@ -6,6 +6,6 @@
/* set a 32-bit const */ /* set a 32-bit const */
mp_err mp_set_int(mp_int *a, unsigned long b) mp_err mp_set_int(mp_int *a, unsigned long b)
{ {
return mp_set_long(a, b & 0xFFFFFFFFUL); return mp_set_long(a, b & 0xFFFFFFFFuL);
} }
#endif #endif

View File

@ -1239,7 +1239,7 @@ static int test_mp_reduce_2k_l(void)
mp_copy(&b, &c); mp_copy(&b, &c);
printf("Testing: mp_reduce_2k_l..."); printf("Testing: mp_reduce_2k_l...");
fflush(stdout); fflush(stdout);
for (cnt = 0; cnt < (int)(1UL << 20); cnt++) { for (cnt = 0; cnt < (int)(1uL << 20); cnt++) {
mp_sqr(&b, &b); mp_sqr(&b, &b);
mp_add_d(&b, 1uL, &b); mp_add_d(&b, 1uL, &b);
mp_reduce_2k_l(&b, &a, &d); mp_reduce_2k_l(&b, &a, &d);