kaitai-io / kaitai_struct

Kaitai Struct: declarative language to generate binary data parsers in C++ / C# / Go / Java / JavaScript / Lua / Nim / Perl / PHP / Python / Ruby
https://kaitai.io
4.04k stars 199 forks source link

Implement 16-bit float from IEEE 754-2008 #1013

Open Theaninova opened 1 year ago

Theaninova commented 1 year ago

16-bit floats are used relatively often in computer graphic formats, like images and 3d files to save space.

Support through languages of course is sparing, but the 16 bit float can be converted to 32-bit through some bit shifting which is even valid in the expression language. (((value & 0x8000) << 16) | (((value & 0x7c00) + 0x1c000) << 13) | ((value & 0x03ff) << 13)).

Some languages also support 16-bit floats, for example C++ through SSE2.

KOLANICH commented 1 year ago

https://github.com/kaitai-io/kaitai_struct_formats/pull/210 and #991 are strongly related