OEHalfFloat

struct OEHalfFloat

This class can be used to store a 32-bit float as a 16-bit float as defined by the IEEE 754-2008 standard. Useful for reducing memory consumption when most of the data is 32-bit floating point values as the expense of precision.

Note

This is a “storage only” class, all math should still be done as float or double and then converted to 16 bits for storage.

Constructors

OEHalfFloat()
OEHalfFloat(double)
OEHalfFloat(float)
OEHalfFloat(long double)
OEHalfFloat(oe_half data)

Default constructors initializes to the value of 0.0. Otherwise convert the value from float, double, or long double and construct with that.

operator double

operator double() const

Retrieve the value as a 64-bit double.

operator float

operator float() const

Retrieve the value as a 32-bit float.

operator long double

operator long double() const

Retrieve the value as the platform dependent long double.

GetValue

float GetValue() const

Retrieve the value as a 32-bit float.