Page 1 of 1

a bit of a maths question

Posted: Mon Oct 14, 2019 3:21 pm
by the7778
i know this is a bit of a maths question but how to i find the decimal opposite of an 8 bit binary number? like inverting all the bits? so say 255 becomes 0 and 0 becomes 255.

like 11111111
00000000

Re: a bit of a maths question

Posted: Mon Oct 14, 2019 3:49 pm
by dr beep
In machinecode with XOR 255
This will swap all 1 to 0 and 0 to 1.

Re: a bit of a maths question

Posted: Mon Oct 14, 2019 3:55 pm
by XavSnap
:lol:

Code: Select all

5 input x
10 LET 255-x

Code: Select all

5 REM XOR 255
10 LET A$="HELLO WORLD"
20 FOR A=1 TO LEN A$
30 LET A$(A)=CHR$(255-CODE A$(A))
40 NEXT A
45 PRINT A$
50 FOR A=1 TO LEN A$
60 LET A$(A)=CHR$(255-CODE A$(A))
70 NEXT A
80 PRINT A$
Have fun.

Re: a bit of a maths question

Posted: Mon Oct 14, 2019 4:41 pm
by the7778
ok, ty


and what about mirroring?

Re: a bit of a maths question

Posted: Mon Oct 14, 2019 8:22 pm
by XavSnap
Yes, next tread…
:geek: