Merge pull request #128 from fperrad/20181128_lint

some linting
This commit is contained in:
Steffen Jaeckel 2018-11-28 12:16:20 +01:00 committed by GitHub
commit 6d4026d582
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 10 additions and 10 deletions

View File

@ -16,14 +16,14 @@
double mp_get_double(const mp_int *a)
{
int i;
double d = 0, fac = 1;
double d = 0.0, fac = 1.0;
for (i = 0; i < DIGIT_BIT; ++i) {
fac *= 2;
fac *= 2.0;
}
for (i = USED(a); i --> 0;) {
d = d * fac + (double)DIGIT(a, i);
d = (d * fac) + (double)DIGIT(a, i);
}
return mp_isneg(a) ? -d : d;
return (mp_isneg(a) != MP_NO) ? -d : d;
}
#endif

View File

@ -14,7 +14,7 @@
*/
#if defined(__STDC_IEC_559__) || defined(__GCC_IEC_559)
int mp_set_double(mp_int *a, double d)
int mp_set_double(mp_int *a, double b)
{
uint64_t frac;
int exp, res;
@ -22,10 +22,10 @@ int mp_set_double(mp_int *a, double d)
double dbl;
uint64_t bits;
} cast;
cast.dbl = d;
cast.dbl = b;
exp = (int)(cast.bits >> 52) & 0x7FF;
frac = (cast.bits & ((1ULL << 52) - 1)) | (1ULL << 52);
exp = (unsigned)(cast.bits >> 52) & 0x7FFU;
frac = (cast.bits & ((1ULL << 52) - 1ULL)) | (1ULL << 52);
if (exp == 0x7FF) { /* +-inf, NaN */
return MP_VAL;
@ -37,8 +37,8 @@ int mp_set_double(mp_int *a, double d)
return res;
}
res = exp < 0 ? mp_div_2d(a, -exp, a, 0) : mp_mul_2d(a, exp, a);
if ((cast.bits >> 63) && !mp_iszero(a)) {
res = (exp < 0) ? mp_div_2d(a, -exp, a, NULL) : mp_mul_2d(a, exp, a);
if (((cast.bits >> 63) != 0ULL) && (mp_iszero(a) == MP_NO)) {
SIGN(a) = MP_NEG;
}