1 #include "tommath_private.h"
3 /* LibTomMath, multiple-precision integer library -- Tom St Denis */
4 /* SPDX-License-Identifier: Unlicense */
6 #if defined(MP_HAS_SET_DOUBLE)
7 mp_err
mp_set_double(mp_int
*a
, double b
)
18 exp
= (int)((unsigned)(cast
.bits
>> 52) & 0x7FFu
);
19 frac
= (cast
.bits
& (((uint64_t)1 << 52) - (uint64_t)1)) | ((uint64_t)1 << 52);
21 if (exp
== 0x7FF) { /* +-inf, NaN */
28 err
= (exp
< 0) ? mp_div_2d(a
, -exp
, a
, NULL
) : mp_mul_2d(a
, exp
, a
);
33 if (((cast
.bits
>> 63) != 0u) && !mp_iszero(a
)) {
40 /* pragma message() not supported by several compilers (in mostly older but still used versions) */
42 # pragma message("mp_set_double implementation is only available on platforms with IEEE754 floating point format")
44 # warning "mp_set_double implementation is only available on platforms with IEEE754 floating point format"