41#define MMGR_DBL_SIGN_MASK 0x8000000000000000ull
42#define MMGR_DBL_EXP_MASK 0x7FF0000000000000ull
43#define MMGR_DBL_MANT_MASK 0x000FFFFFFFFFFFFFull
44#define MMGR_DBL_SIGN_SHIFT 63u
45#define MMGR_DBL_MANT_BITS 52u
46#define MMGR_DBL_EXP_BITS 11u
47#define MMGR_DBL_SIGN_ONE 0x1ull
48#define MMGR_DBL_EXP_ALL 0x7FFull
49#define MMGR_DBL_BIAS 1023
60#define MMGR_DBL_BITS 64u
61#define MMGR_DBL_BYTES (MMGR_DBL_BITS / 8u)
62#define MMGR_DBL_WORDS \
63 ((MMGR_DBL_BITS + (EMBED_WORD_BITS - 1u)) / EMBED_WORD_BITS)
72 "double is not 64 bits on this target, so every field position in this file is wrong "
73 "- a build where double means float cannot use it");
75 "a double is not a whole number of words on this target");
76EMBED_STATIC_ASSERT(
sizeof(embed_u64) ==
sizeof(
double),
"the bit pattern of a double does not fit embed_u64");
86 "the three fields do not add up to the width of the value");
88 "the three field masks leave a gap");
91 "the three field masks overlap");
93 "the sign mask and the sign shift disagree about where the sign is");
95 "the exponent mask and the exponent width disagree");
107#define MMGR_DBL_SCALE_MAX ((embed_iword)(MMGR_DBL_EXP_ALL - 1u) - MMGR_DBL_BIAS - (embed_iword)MMGR_DBL_MANT_BITS)
108#define MMGR_DBL_SCALE_MIN (1 - MMGR_DBL_BIAS - (embed_iword)MMGR_DBL_MANT_BITS)
113EMBED_STATIC_ASSERT(
MMGR_DBL_SCALE_MAX == 971,
"the largest scale a finite double can carry is not what it was");
114EMBED_STATIC_ASSERT(MMGR_DBL_SCALE_MIN == -1074,
"the smallest scale a subnormal can carry is not what it was");
126 const embed_u64
bits;
148EMBED_TABLE_LAYOUT(
FractioNs, sign, exp, mant, merge, from_bits, to_bits);
embed_u64 mmgr_fract_merge(const FractioCfg *args)
Packs args->sign, args->exp and args->mant into one bit pattern.
embed_u64 mmgr_fract_mant(const FractioCfg *args)
Returns the mantissa field of args->bits.
#define MMGR_DBL_MANT_BITS
#define MMGR_DBL_BITS
The width of a double in bits, bytes and embed_word units.
embed_u64 mmgr_fract_to_bits(const FractioCfg *args)
Reads the union as a bit pattern.
#define MMGR_DBL_EXP_MASK
embed_u64 mmgr_fract_sign(const FractioCfg *args)
Returns the sign bit of args->bits.
embed_u64 mmgr_fract_exp(const FractioCfg *args)
Returns the exponent field of args->bits.
double mmgr_fract_from_bits(const FractioCfg *args)
Reads the union as a double.
#define MMGR_DBL_MANT_MASK
static const FractioNs fract
Dispatch table instance named fract, whose members are the mmgr_fract_ entries.
#define MMGR_DBL_SIGN_SHIFT
#define MMGR_DBL_EXP_BITS
#define MMGR_DBL_SIGN_ONE
#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)