Hi group,
I'm trying to create a helper function to convert a floating point number to a group of bytes
For example I have this value: 146.52000
I think I need it change to something like 0x01,0x04,0x06,0x05,0x02,0x00,0x00,0x00
The first thing I beieve I need to do is shift the decimal point to the right 5 places. So I did this
real_freq *= 100000.0
I believe this gets me 14652000
Now I think I need to do something like this to separate the individual digits
digits =[int(i) for i in str(real_freq)]
I'm not positive, but I think this makes an array something like
digits[0] = 1
digits[1] = 4
digits[2] = 6
digits[3] = 5
digits[4] = 2
digits[5] = 0
digits[6] = 0
digits[7] = 0
Here is where I'm stuck. I've tried a few think but so far no luck. I've searched the other drivers to see if I could locate something similar. If there is, I missed it.
Then ultimately, I think I need to end with
return bytes
So am I on the right track? Any advice on what I need to do next.
Thanks,
Jim