I want to obtain the binary representation of a variable x
in half precision floating point representation. x
can be anything (like -1.25 or 10 etc). I have tried quite a few things but can't really get this right.
I have tried making my own function but it doesn't work for all numbers. It's filled with bugs.
I have tried using struct but I don't really know much on how to use it.
var = pack('e', 0.25)
t = unpack('H',var)
bin(t[0] & 0xffff)
This doesn't seem to give correct representation.