2's Complement help

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?

  1. Cast the float as a long
  2. & the long with 0x80 to check if negative or not
  3. If Negative take the 2’s complement
  4. take 2’s complement by ~ long +1
  5. that should be the value i’m looking for right?

Thanks for your help.