How can I convert an integer to a half precision float (which is to be stored into an array unsigned char[2]). The range to the input int will be from 1-65535. Precision is really not a concern.
I am doing something similar for converting to 16bit int into an unsigned char[2], but I understand there is not half precision float C++ datatype. Example of this below:
int16_t position16int = (int16_t)data;
memcpy(&dataArray, &position16int, 2);
It’s a very straightforward thing, all the info you need is in Wikipedia.
Sample implementation:
Output (ideone):