How do I inverse a number?

Man, I used to know this but tonight, I just can't seem to get it back... If I have a variabe that is coming in at between 0 and 255 and I need it inverted so that 0 is now 255 and 255 is now 0, what is the equasion? This should be so simple, I just can't seem to remember how to do it!

C'mon math Gods, gimme what you got!!

Convert to 8 bit binary and

Convert to 8 bit binary and NOT it. 01010101 becomes 10101010

 

http://en.wikipedia.org/wiki/Bitwise_operation#NOT

well…
I need it in picaxe --it has to be a if/ then or a add and subtract kinda thing…

your number - 255if result

your number - 255

if result is < 0 then multiply by -1

close but no cigar…
picaxe does not do negitive numbers…

255 - your number the result
255 - your number the result is the inverse.

because of the wrap-around on bytes!!!
My boy, I think you’ve got it! (English accent)

I love how I went with the
I love how I went with the hard solutions first.

don’t you just shift a bit

don’t you just shift a bit over 1? picaxe can do this…

edit: sorry being mental, I read it in the same area, the command is REV…

Ha I was surprised someone
Ha I was surprised someone as smart as you, CTC, wouldn’t know how to do that XD.