How do I invert all the bits in a byte?

Eg %011010110 would become %100101001

I assumed, then read it was by using the tilde (~) function but I'm having trouble using it in code.

eg if I had byteA=%011010110

and I did this: byteA=~byteA, shouldn't ~byteA display %100101001?

Strangely I can display the value of byteA in the display (LabX1) but ~byteA comes up empty.