|
NEP 4.3.0
NetCDF Expansion Pack
|
Conversions between IEEE 754 float32 and bfloat16 bit patterns. More...
Go to the source code of this file.
Macros | |
| #define | BF16_FILL_IN 9.99e+20f |
| #define | BF16_REL_ERR_MAX 0.00390625 |
Functions | |
| static uint16_t | float_to_bfloat16 (float f) |
| Convert a float32 to a bfloat16 bit pattern, round to nearest, ties to even. | |
| static float | bfloat16_to_float (uint16_t b) |
| Convert a bfloat16 bit pattern to float32 (exact). | |
Conversions between IEEE 754 float32 and bfloat16 bit patterns.
nxCDF stores NC_BFLOAT16 variables as raw 16-bit bfloat16 bit patterns; conversion to and from float32 is done in user code. This header provides the two conversions used by the nxCDF bfloat16 examples.
| #define BF16_FILL_IN 9.99e+20f |
GDAS input fill value; points equal to it are left out of error metrics.
| #define BF16_REL_ERR_MAX 0.00390625 |
Maximum relative error for bfloat16 round-to-nearest (2^-8).
|
inlinestatic |
Convert a bfloat16 bit pattern to float32 (exact).
| b | The bfloat16 bit pattern. |
|
inlinestatic |
Convert a float32 to a bfloat16 bit pattern, round to nearest, ties to even.
NaN stays a quiet NaN. Values that round past the bfloat16 maximum overflow to infinity, which is correct.
| f | The float32 value to convert. |