25 #ifndef CBORINTERNAL_P_H
26 #define CBORINTERNAL_P_H
30 #ifndef CBOR_NO_FLOATING_POINT
34 # ifndef CBOR_NO_HALF_FLOAT_TYPE
35 # define CBOR_NO_HALF_FLOAT_TYPE 1
39 #ifndef CBOR_NO_HALF_FLOAT_TYPE
41 # include <immintrin.h>
42 static inline unsigned short encode_half(
double val)
44 return _cvtss_sh((
float)val, 3);
46 static inline double decode_half(
unsigned short half)
48 return _cvtsh_ss(half);
56 memcpy(&v, &val,
sizeof(v));
58 exp = (v >> 52) & 0x7ff;
59 mant = v << 12 >> 12 >> (53-11);
65 }
else if (exp >= 16) {
69 }
else if (exp >= -14) {
71 }
else if (exp >= -24) {
82 return (
unsigned short)(sign | ((exp + 15) << 10) | mant);
88 int exp = (half >> 10) & 0x1f;
89 int mant = half & 0x3ff;
91 if (exp == 0) val = ldexp(mant, -24);
92 else if (exp != 31) val = ldexp(mant + 1024, exp - 25);
93 else val = mant == 0 ? INFINITY : NAN;
94 return half & 0x8000 ? -val : val;
99 #ifndef CBOR_INTERNAL_API
100 # define CBOR_INTERNAL_API
103 #ifndef CBOR_PARSER_MAX_RECURSIONS
104 # define CBOR_PARSER_MAX_RECURSIONS 1024