40 #ifndef WFIO_IEEE754_H 41 #define WFIO_IEEE754_H 45 #include <wfcnfo/float.h> 52 #define WFIO_IEEE754_NATIVE_B16 57 #define WFIO_IEEE754_NATIVE_B32 62 #define WFIO_IEEE754_NATIVE_B64 66 #ifdef WFCNFO_IEEE754_NATIVE_B16 67 #define WFIO_IEEE754_NATIVE_B16 70 #ifdef WFCNFO_IEEE754_NATIVE_B32 71 #define WFIO_IEEE754_NATIVE_B32 74 #ifdef WFCNFO_IEEE754_NATIVE_B64 75 #define WFIO_IEEE754_NATIVE_B64 78 #ifdef WFCNFO_FLT_IS_IEEE754 79 #define WFIO_FLT_IS_IEEE754 83 #if defined(WFIO_IEEE754_NATIVE_B32) && defined(WFIO_IEEE754_NATIVE_B64) 87 #define WFIO_IEEE754_NATIVE 93 #undef WFIO_IEEE754_NATIVE_B16 94 #undef WFIO_IEEE754_NATIVE_B32 95 #undef WFIO_IEEE754_NATIVE_B64 96 #undef WFIO_IEEE754_NATIVE 98 #define WFIO_MAYBE_INLINE WFIO_DLL 135 #ifdef WFIO_IEEE754_NATIVE_B16 174 #ifdef WFIO_IEEE754_NATIVE_B32 221 #ifdef WFIO_IEEE754_NATIVE_B64 229 #ifdef WFIO_FLT_IS_IEEE754 230 #if WFIO_ENDIAN_HOST_REPORTED==WFIO_ENDIAN_FLT_REPORTED 231 #define WFIO_IEEE754_SET_(R, X, N) (R).host_ = X 232 #define WFIO_IEEE754_GET_(X, N) (X).host_ 234 #elif (WFIO_ENDIAN_IS_BIG_ENDIAN | WFIO_ENDIAN_HOST_IS_LIL) == 3 235 #define WFIO_IEEE754_SET_(R, X, N) (R).si = wfio_swapSI##N((\ 236 (wfio_ieee754_b##N##_t*) &X)->si) 237 #define WFIO_IEEE754_GET_(X, N) wfio_swapSI32((X).si) 241 #define WFIO_IEEE754_SET_(R, X, N) (R).si = wfio_toHostEndianSI##N((\ 242 (wfio_ieee754_b##N##_t*) &X)->si, WFIO_ENDIAN_FLT) 243 #define WFIO_IEEE754_GET_(X, N) ((X).si = wfio_fromHostEndianSI##N((X).si,\ 244 WFIO_ENDIAN_FLT), (X).host_) 252 #define WFIO_IEEE754_B32_MIN (wfio_ieee854_b32_t) 0x1 258 #define WFIO_IEEE754_B32_MAX (wfio_ieee754_b32_t) 0x7EFFFFFF 264 #define WFIO_IEEE754_B32_INF (wfio_ieee754_b32_t) 0x7F000000 266 #define WFIO_IEEE754_B32_ENAN (wfio_ieee754_b32_t) 0x7FFFFFFF 271 WFIO_IEEE754_B32_ENAN_RAW = 0x7FFFFFFF,
272 WFIO_IEEE754_B64_ENAN_RAW = 0x7FFFFFFFFFFFFFFF,
276 #ifdef WFIO_IEEE754_NATIVE_B32 280 WFIO_IEEE754_SET_(ret, host, 32);
286 return WFIO_IEEE754_GET_(ieee, 32);
322 #ifdef WFIO_IEEE754_NATIVE_B64 326 WFIO_IEEE754_SET_(ret, host, 64);
332 return WFIO_IEEE754_GET_(ieee, 64);
367 #ifdef WFIO_MAYBE_INLINE 368 #undef WFIO_MAYBE_INLINE union wfio_ieee754_b32_t wfio_ieee754_b32_t
A single-precision IEEE 754 binary floating point value (binary32).
A double-precision IEEE 754 binary floating point value (binary64).
Definition: ieee754.h:196
#define WFIO_MAYBE_INLINE
Potentially mark this symbol for inlining.
Definition: host.h:466
wfio_uint32_t significand
Definition: ieee754.h:155
wfio_uint64_t exponent
Definition: ieee754.h:204
#define WFIO_DLL
Mark the symbol as an element of the library.
Definition: host.h:397
#define WFIO_C_BEGIN
Definition: host.h:477
wfio_uint16_t sign
Definition: ieee754.h:121
wfio_uint16_t exponent
Definition: ieee754.h:119
WFIO_MAYBE_INLINE wfio_flt32_t wfio_ieee754_fromB32(wfio_ieee754_b32_t ieee, int *error)
Convert a 32-bit floating point number from IEEE 754 binary32 format.
wfio_uint64_t sign
Definition: ieee754.h:206
#define WFIO_ALWAYS_INLINE
Mark this symbol to be forced inline.
Definition: host.h:447
wfio_sint64_t si
The raw signed 64-bit integer representation of this number.
Definition: ieee754.h:213
WFIO_MAYBE_INLINE wfio_ieee754_b32_t wfio_ieee754_toB32(wfio_flt32_t host, int *error)
Convert a 32-bit floating point number to IEEE 754 binary32 format.
wfio_uint64_t significand
Definition: ieee754.h:202
Endian manipulation functions.
A single-precision IEEE 754 binary floating point value (binary32).
Definition: ieee754.h:149
wfio_uint16_t ui
The raw unsigned 16-bit integer representation of this number.
Definition: ieee754.h:133
wfio_sint16_t si
The raw signed 16-bit integer representation of this number.
Definition: ieee754.h:127
wfio_sint32_t si
The raw signed 32-bit integer representation of this number.
Definition: ieee754.h:166
wfio_uint32_t ui
The raw unsigned 32-bit integer representation of this number.
Definition: ieee754.h:172
wfio_uint64_t ui
The raw unsigned 64-bit integer representation of this number.
Definition: ieee754.h:219
wfio_uint32_t exponent
Definition: ieee754.h:157
wfio_uint32_t sign
Definition: ieee754.h:159
#define WFIO_C_END
Definition: host.h:485
WFIO_MAYBE_INLINE wfio_flt64_t wfio_ieee754_fromB64(wfio_ieee754_b64_t ieee, int *error)
Convert a 64-bit floating point number from IEEE 754 binary64 format.
WFIO_C_BEGIN union wfio_ieee754_b16_t wfio_ieee754_b16_t
A half-precision IEEE 754 binary floating point value (binary16).
wfio_uint16_t significand
Definition: ieee754.h:117
A half-precision IEEE 754 binary floating point value (binary16).
Definition: ieee754.h:111
WFIO_DLL wfio_ieee754_b64_t wfio_ieee754_toB64(wfio_flt64_t host, int *error)
Convert a 64-bit floating point number to IEEE 754 binary64 format.
struct wfio_ieee754_b16_t::@6 bits
The bit pattern for this number.
A structure indicating no definition.
Definition: misctype.h:47
union wfio_ieee754_b64_t wfio_ieee754_b64_t
A double-precision IEEE 754 binary floating point value (binary64).