Read half precision float (float16 IEEE 754r) binary data in matlab

Posted by Michael on Stack Overflow See other posts from Stack Overflow or by Michael
Published on 2012-09-11T03:24:50Z Indexed on 2012/09/11 3:38 UTC
Read the original article Hit count: 754

Filed under:
|
|
|
|

you have been a great help last time, i hope you can give me some advise this time, too.

I read a binary file into matlab with bit16 (format = bitn) and i get a string of ones and zeros.

bin = '1 00011 1111111111' (16 bits: 1. sign, 2-6. exponent, 7-16. mantissa)

According to ftp://www.fox-toolkit.org/pub/fasthalffloatconversion.pdf it can be 'converted' like

out = (-1)^bin(1) * 2^(bin(2:6)-15) * 1.bin(7:16) [are exponent and mantissa still binary?]

Can someone help me out and tell me how to deal with the 'eeeee' and '1.mmmmmmmmmm' as mentioned in the pdf, please.

Thanks a lot!

Michael

© Stack Overflow or respective owner

Related posts about matlab

Related posts about floating-point