11 static constexpr double NANVAL = std::numeric_limits<double>::quiet_NaN();
12 static constexpr double INFVAL = std::numeric_limits<double>::infinity();
14 if (v & 0x8000000000000000) {
16 v ^= 0x8000000000000000;
19 if (v == 0)
return copysign(0.0,
sign);
21 if (v == 0x7ff0000000000000)
return copysign(INFVAL,
sign);
23 int exp = (v & 0x7FF0000000000000) >> 52;
24 uint64_t man = v & 0xFFFFFFFFFFFFF;
28 }
else if (exp == 0) {
30 return copysign(ldexp((
double)man, -1074),
sign);
33 return copysign(ldexp((
double)(man + 0x10000000000000), -1075 + exp),
sign);
38 int cls = std::fpclassify(f);
40 if (copysign(1.0, f) == -1.0) {
42 sign = 0x8000000000000000;
45 if (cls == FP_ZERO)
return sign;
47 if (cls == FP_INFINITE)
return sign | 0x7ff0000000000000;
49 if (cls == FP_NAN)
return 0x7ff8000000000000;
52 uint64_t man = std::round(std::frexp(f, &exp) * 9007199254740992.0);
55 if (exp < -1084)
return sign;
57 return sign | (man >> (-1021 - exp));
60 if (exp > 1024)
return sign | 0x7ff0000000000000;
62 return sign | (((uint64_t)(1022 + exp)) << 52) | (man & 0xFFFFFFFFFFFFF);
static int sign(const secp256k1_context *ctx, struct signer_secrets *signer_secrets, struct signer *signer, const secp256k1_musig_keyagg_cache *cache, const unsigned char *msg32, unsigned char *sig64)
uint64_t EncodeDouble(double f) noexcept
double DecodeDouble(uint64_t v) noexcept