Alright Folks I need some help and would be thankful for some direction.
I am trying to take the 2’s complement of a signed float. This float comes from a struct that is polling the data through a RS-485 port. So it originally comes in as a struct…
I’m pretty sure only longs ints and chars can have the 2’s complement taken. Is that correct?
- Cast the float as a long
- & the long with 0x80 to check if negative or not
- If Negative take the 2’s complement
- take 2’s complement by ~ long +1
- that should be the value i’m looking for right?
Thanks for your help.