I need to convert a float value to binary. This value can be from 0 to 99.99.
I saw that if the value is an int and between 0 to 255 I just have to do
n = [255]
num = byte(n)
How is not possible directly convert a float to binary (I think), my first step was multiply my float number *100 and have an integer from 0 to 9999.
Now I need 4 bytes to represent the number.
It is possible do something like this arduino code (below)?
n = 9999
byte = pl[4];
pl[0] = (byte) ((n & 0xFF000000) >> 24 );
pl[1] = (byte) ((n & 0x00FF0000) >> 16 );
pl[2] = (byte) ((n & 0x0000FF00) >> 8 );
pl[3] = (byte) ((n & 0X000000FF));
Basically I'm applying a mask, but I don't know how to do it with python because I'm a noob. :/
MORE INFO:
The objective is to reduce the length of my result to send this with a wireless protocol. That's why I'm converting it to byte.
Thank you very much
1100.100010or after multiplying it with 100, you want010011010010??intvalue,1234