|
NEP 4.3.0
NetCDF Expansion Pack
|
Conversions between IEEE 754 float32 and binary16 bit patterns. More...
Go to the source code of this file.
Macros | |
| #define | F16_FILL_IN 9.99e+20f |
| #define | F16_REL_ERR_MAX 0.00048828125 |
| #define | F16_ABS_ERR_MAX 2.9802322387695312e-08 |
Functions | |
| static uint16_t | float_to_float16 (float f) |
| Convert a float32 to an IEEE 754 binary16 bit pattern, round to nearest, ties to even. | |
| static float | float16_to_float (uint16_t h) |
| Convert an IEEE 754 binary16 bit pattern to float32 (exact). | |
Conversions between IEEE 754 float32 and binary16 bit patterns.
nxCDF stores NC_FLOAT16 variables as raw 16-bit IEEE 754 binary16 bit patterns; conversion to and from float32 is done in user code. This header provides the two conversions used by the nxCDF float16 examples.
| #define F16_ABS_ERR_MAX 2.9802322387695312e-08 |
Absolute-error floor: half the smallest binary16 subnormal (2^-25). A point also passes when its absolute error is under this floor, so subnormal underflow does not fail the gate.
| #define F16_FILL_IN 9.99e+20f |
GDAS input fill value; points equal to it are left out of error metrics.
| #define F16_REL_ERR_MAX 0.00048828125 |
Maximum relative error for binary16 round-to-nearest (2^-11).
|
inlinestatic |
Convert an IEEE 754 binary16 bit pattern to float32 (exact).
| h | The binary16 bit pattern. |
|
inlinestatic |
Convert a float32 to an IEEE 754 binary16 bit pattern, round to nearest, ties to even.
NaN stays a quiet NaN. Finite magnitudes of 65520 or more overflow to infinity; magnitudes in (65504, 65520) round to the largest finite value 0x7bff. Results below 2^-14 become subnormals or signed zero.
| f | The float32 value to convert. |