44#define MMGR_DBL_SIGN_MASK 0x8000000000000000ull
45#define MMGR_DBL_EXP_MASK 0x7FF0000000000000ull
46#define MMGR_DBL_MANT_MASK 0x000FFFFFFFFFFFFFull
47#define MMGR_DBL_SIGN_SHIFT 63u
48#define MMGR_DBL_MANT_BITS 52u
49#define MMGR_DBL_EXP_BITS 11u
50#define MMGR_DBL_SIGN_ONE 0x1ull
51#define MMGR_DBL_EXP_ALL 0x7FFull
52#define MMGR_DBL_BIAS 1023
63#define MMGR_DBL_BITS 64u
64#define MMGR_DBL_BYTES (MMGR_DBL_BITS / 8u)
65#define MMGR_DBL_WORDS \
66 ((MMGR_DBL_BITS + (EMBED_WORD_BITS - 1u)) / EMBED_WORD_BITS)
75 "double is not 64 bits on this target, so every field position in this file is wrong "
76 "- a build where double means float cannot use it");
78 "a double is not a whole number of words on this target");
79EMBED_STATIC_ASSERT(
sizeof(embed_u64) ==
sizeof(
double),
"the bit pattern of a double does not fit embed_u64");
89 "the three fields do not add up to the width of the value");
91 "the three field masks leave a gap");
94 "the three field masks overlap");
96 "the sign mask and the sign shift disagree about where the sign is");
98 "the exponent mask and the exponent width disagree");
110#define MMGR_DBL_SCALE_MAX ((embed_iword)(MMGR_DBL_EXP_ALL - 1u) - MMGR_DBL_BIAS - (embed_iword)MMGR_DBL_MANT_BITS)
111#define MMGR_DBL_SCALE_MIN (1 - MMGR_DBL_BIAS - (embed_iword)MMGR_DBL_MANT_BITS)
116EMBED_STATIC_ASSERT(
MMGR_DBL_SCALE_MAX == 971,
"the largest scale a finite double can carry is not what it was");
117EMBED_STATIC_ASSERT(MMGR_DBL_SCALE_MIN == -1074,
"the smallest scale a subnormal can carry is not what it was");
129 const embed_u64
bits;
151EMBED_TABLE_LAYOUT(
FractioNs, sign, exp, mant, merge, from_bits, to_bits);
#define MMGR_DBL_MANT_BITS
#define MMGR_DBL_BITS
The width of a double in bits, bytes and embed_word units.
EMBED_HOST_DEVICE embed_u64 mmgr_fract_mant(const FractioCfg *args)
Returns the mantissa field of args->bits.
#define MMGR_DBL_EXP_MASK
EMBED_HOST_DEVICE embed_u64 mmgr_fract_to_bits(const FractioCfg *args)
Reads the union as a bit pattern.
#define MMGR_DBL_MANT_MASK
EMBED_HOST_DEVICE double mmgr_fract_from_bits(const FractioCfg *args)
Reads the union as a double.
static const FractioNs fract
Dispatch table instance named fract, whose members are the mmgr_fract_ entries.
EMBED_HOST_DEVICE embed_u64 mmgr_fract_exp(const FractioCfg *args)
Returns the exponent field of args->bits.
#define MMGR_DBL_SIGN_SHIFT
#define MMGR_DBL_EXP_BITS
EMBED_HOST_DEVICE embed_u64 mmgr_fract_merge(const FractioCfg *args)
Packs args->sign, args->exp and args->mant into one bit pattern.
#define MMGR_DBL_SIGN_ONE
EMBED_HOST_DEVICE embed_u64 mmgr_fract_sign(const FractioCfg *args)
Returns the sign bit of args->bits.
#define MMGR_DBL_SIGN_MASK
The binary64 field layout: three masks, the sign shift, the two field widths, the two whole field val...
#define MMGR_DBL_SCALE_MAX
Pins the target's double to the width and storage this file assumes.
The embedded_types headers every module builds on.
Pins the two scale bounds to the values binary64 gives.
Type of the fract dispatch table.
embed_u64(*) to_bits(const FractioCfg *args)
embed_u64(*) mant(const FractioCfg *args)
embed_u64(*) exp(const FractioCfg *args)
double(*) from_bits(const FractioCfg *args)
embed_u64(*) sign(const FractioCfg *args)
embed_u64(*) merge(const FractioCfg *args)