I
I
im_noob2021-04-29 15:07:27
Algorithms
im_noob, 2021-04-29 15:07:27

Operations AND, OR, XOR How to check bits?

Please explain how to check the bits because I didn’t find anything sensible on the Internet

There is an example in the lecture, but it’s not clear what is done and how.
Where does the value 34 come from?
From the lecture:
608aa173c477c338711629.png
I tried to do my lecture assignment, but I really didn’t understand anything.
I have a task: to check the state of the n-1st and n-th bits of A; turn off the 2nd and 7th bits of B;
turn on the 3rd and 4th bits of A; toggle nth bit B;
Judging by the material from the lecture:
So I should write:
A=230
n=2
X AND (2^1+2^2) OR X AND 230

B=221

X AND (255–2^2–2^7) OR X AND 221

X OR (2^3+2^4) OR X OR 230

X XOR (2^2) OR X OR 221

Answer the question

In order to leave comments, you need to log in

1 answer(s)
W
Wataru, 2021-04-29
@im_noob

X AND (2^1+2^2) OR X AND 230

On the left, it is correctly written, but somehow you got 230 out of 2 + 4.
X AND (255–2^2–2^7) OR X AND 221

The same. They did the correct operation, but somehow from 255-4-128 they got 221, although it should be 123.
And instead of X, write A or B in tasks. Further the same errors.

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question