[Hdf-forum] Half precision floating-point format, implemented!

Dimitris Servis servisster at gmail.com
Mon Jan 11 10:16:49 EST 2010


Hi all,

just wanted to report that the half precision (16bit) floating point works
great with HDF5. I implemented some in-place array conversion functions (for
a good implementation with ample room of improvement see
http://www.mathworks.com/matlabcentral/fileexchange/23173-ieee-754r-half-precision-floating-point-converter).
The in-place replacement is straight forward to implement. I also
implemented a half float type to use with C++ and standard containers. On
the HDF5 side, I used the in-place array converters to register the new type
using code like this:

hid_t halftype = H5Tcopy(H5T_NATIVE_FLOAT);
H5Tset_fields(halftype , 15, 10, 5, 0, 10);
H5Tset_size(halftype , 2);
H5Tregister(H5T_PERS_HARD, "half-to-float",  halftype , H5T_NATIVE_FLOAT,
half_conversion_function);
(the same for all possible conversions)

So far it works great. I can convert from any array to half float and back.
Disk usage is obviously halved, so is memory usage, especially if you're on
the C++ side where it is easier to work with the custom half type.

HTH

-- dimitris
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mail.hdfgroup.org/pipermail/hdf-forum_hdfgroup.org/attachments/20100111/495e66ce/attachment.html>


More information about the Hdf-forum mailing list