converting negative float numbers to unsigned int
Im trying to send a unsigned int data from a C server to a python client.
The requirement is to send a negative float value to the client. currently
the number is -5.700 and I have 2 problems. 1) I dont have a clue on how
to retain the negativeness within uint32_t, im using the MSB as a flag bit
to get around it. Is this fine? Does anyone has better suggestions?
2) I tried typecasting float 5.700 to uint32_t, i.e uint32_t fops =
*(uint32_t*)(&float_var) //float_var is 5.700 And fops was assigned value
0x00..006666 (decimal = 26214) which is being sent to the python client.
now how do I retrieve the float back from this value at the client?
No comments:
Post a Comment