Let's Make Robots!

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!!

Comment viewing options

Select your preferred way to display the comments and click "Save settings" to activate your changes.
Ha I was surprised someone as smart as you, CTC, wouldn't know how to do that XD.

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....

My boy, I think you've got it! (English accent)
I love how I went with the hard solutions first.

Your first way was just as easy but CTC was too lazy to RTFM!


picaxe does not do negitive numbers...
255 - your number the result is the inverse.
I need it in picaxe --it has to be a if/ then or a add and subtract kinda thing..

your number - 255

if result is < 0 then multiply by -1

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