C-language half-float Conversion

The half.h header can be included in pure C code:

#include <Imath/half.h>

void
half_example ()
{
    float f = 3.5f;

    half h = imath_float_to_half (f)

        float hh = imath_half_to_float (h)
}

The only C-language operations supported for the half type are conversion to and from float. No arithmetic operations are currently implemented in the C interface.

static inline float imath_half_to_float(half h)

Convert half to float.

static inline half imath_float_to_half(float f)

Convert half to float.

Note: This only supports the “round to even” rounding mode, which was the only mode supported by the original OpenEXR library