Wheefun I/O Library
0.0.5
Useful I/O Primitives.
|
IEEE754 floating point manipulation. More...
Go to the source code of this file.
Classes | |
union | wfio_ieee754_b16_t |
A half-precision IEEE 754 binary floating point value (binary16). More... | |
union | wfio_ieee754_b32_t |
A single-precision IEEE 754 binary floating point value (binary32). More... | |
union | wfio_ieee754_b64_t |
A double-precision IEEE 754 binary floating point value (binary64). More... | |
Macros | |
#define | WFIO_IEEE754_NATIVE_B16 |
A macro indicating that there is native support for IEEE 754 numbers in binary16 format. | |
#define | WFIO_IEEE754_NATIVE_B32 |
A macro indicating that there is native support for IEEE 754 numbers in binary32 format. | |
#define | WFIO_IEEE754_NATIVE_B64 |
A macro indicating that there is native support for IEEE 754 numbers in binary64 format. | |
#define | WFIO_IEEE754_NATIVE |
Synonymous with WFIO_IEEE754_NATIVE_B32 && WFIO_IEEE_NATIVE_B64. | |
#define | WFIO_IEEE754_B32_MIN (wfio_ieee854_b32_t) 0x1 |
A constant representing the minimum positive, nonzero value for an IEEE 754 binary32 number. | |
#define | WFIO_IEEE754_B32_MAX (wfio_ieee754_b32_t) 0x7EFFFFFF |
A constant representing the maximum positive, non-infinite value for an IEEE 754 binary32 number. | |
#define | WFIO_IEEE754_B32_INF (wfio_ieee754_b32_t) 0x7F000000 |
A constant representing the positive infinite value for an IEEE 754 binary32 number. | |
#define | WFIO_IEEE754_B32_ENAN (wfio_ieee754_b32_t) 0x7FFFFFFF |
Typedefs | |
typedef WFIO_C_BEGIN union wfio_ieee754_b16_t | wfio_ieee754_b16_t |
A half-precision IEEE 754 binary floating point value (binary16). More... | |
typedef union wfio_ieee754_b32_t | wfio_ieee754_b32_t |
A single-precision IEEE 754 binary floating point value (binary32). More... | |
typedef union wfio_ieee754_b64_t | wfio_ieee754_b64_t |
A double-precision IEEE 754 binary floating point value (binary64). More... | |
Enumerations | |
enum | { WFIO_IEEE754_B32_ENAN_RAW = 0x7FFFFFFF, WFIO_IEEE754_B64_ENAN_RAW = 0x7FFFFFFFFFFFFFFF } |
Functions | |
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. More... | |
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. More... | |
WFIO_DLL size_t | wfio_ieee754_toB32V2 (const wfio_flt32_t *src, wfio_ieee754_b32_t *dest, size_t len, int *error) |
WFIO_DLL size_t | wfio_ieee754_fromB32V2 (const wfio_ieee754_b32_t *src, wfio_flt32_t *dest, size_t len, int *error) |
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. More... | |
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. More... | |
WFIO_DLL size_t | wfio_ieee754_toB64V2 (const wfio_flt64_t *src, wfio_ieee754_b64_t *dest, size_t len, int *error) |
WFIO_DLL size_t | wfio_ieee754_fromB64V2 (const wfio_ieee754_b64_t *src, wfio_flt64_t *dest, size_t len, int *error) |
IEEE754 floating point manipulation.
This header provides IEEE 754 support for architectures which do not support it. This is necessary because although most modern machines do implement this standard, many do not. Furthermore, there have been extensions to the standard since when it was first published in 1985. This header is provided so that these numbers may be easily written to a device or stream.
This header only implements the basic binary formats. For extended support, link against libwfion and include wfio/num/ieee754.h.
typedef WFIO_C_BEGIN union wfio_ieee754_b16_t wfio_ieee754_b16_t |
A half-precision IEEE 754 binary floating point value (binary16).
This type arises from IEEE 754-2008 and represents a half-precision floating point number. This can fit within exactly 16 bits and may be used in situations where the range does not exceed ± ~2^15. in total, there are 11 bits of precision in the significand.
typedef union wfio_ieee754_b32_t wfio_ieee754_b32_t |
A single-precision IEEE 754 binary floating point value (binary32).
This type arises from IEEE 754-1985 and represents a single-precision floating point number. This can fit within exactly 32 bits and may be used in situations where the range does not exceed ± ~2^127. In total, there are 24 bits of precision in the significand.
typedef union wfio_ieee754_b64_t wfio_ieee754_b64_t |
A double-precision IEEE 754 binary floating point value (binary64).
This type arises from IEEE 754-1985 and represents a single-precision floating point number. This can fit within exactly 32 bits and may be used in situations where the range does not exceed ± ~2^1024. In total, there are 53 bits of precision in the significand.
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.
ieee | The number to convert. |
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.
ieee | The number to convert. |
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.
host | The number to convert. |
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.
host | The number to convert. |