.. oe:namespace:: OEPlatform


.. meta::
   :keywords: OEHalfFloat, HalfFloat


.. _OEPlatform_OEHalfFloat:

.. oe:class:: OEHalfFloat

   .. oe:api::

      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.

   
   .. oe:method:: Constructors

      .. oe:language:: c++ java csharp

         .. oe:api::

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

      .. oe:language:: python

         .. oe:api:: python

            OEHalfFloat() -> OEHalfFloat
            OEHalfFloat(data: oe_half) -> OEHalfFloat
            OEHalfFloat(data: int) -> OEHalfFloat
            OEHalfFloat(arg2: float) -> OEHalfFloat
            OEHalfFloat(float: int) -> OEHalfFloat

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

   .. oe:method:: operator double
      :language: c++

      .. oe:api::

         operator double() const

      Retrieve the value as a 64-bit ``double``. 

   .. oe:method:: operator float
      :language: c++ java

      .. oe:api::

         operator float() const

      Retrieve the value as a 32-bit ``float``. 

   .. oe:method:: operator long double
      :language: c++ java

      .. oe:api::

         operator long double() const

      Retrieve the value as the platform dependent ``long double``. 


   .. oe:method:: GetValue

      .. oe:language:: c++ java csharp

         .. oe:api::

            float GetValue() const

      .. oe:language:: python

         .. oe:api:: python

            GetValue() -> float

      Retrieve the value as a 32-bit float. 

