You are on page 1of 2

Name: John Allen E.

Atutubo Teacher: Sir Kenneth Lawas


Section: 11STEM(E)-2 Subject: Computer Programming 1

Activity 2

1. Create a bitwise AND (&) for numbers 94 & 65 (3 points)


94 & 65= 64 1011110
Bit 94 = 1011110 & 1000001
Operation: 65 = 1000001 1000000 = 64

2. Create a bitwise OR (|) for numbers 524 & 303 (3 points)


524 | 303 = 815 1000001100
Bit 524 = 1000001100 | 0100101111
Operation: 303 = 100101111 1100101111 = 815

3. Create a bitwise XOR (^) for numbers 1201 & 1110 (3 points)
1201 ^ 1110 = 231 10010110001
Bit 1201 = 10010110001 ^ 10001010110
Operation: 1110 = 10001010110 00011100111 = 231

4. Create a bitwise complement (~) for 121 (3 points)


~121 ~ 001111001
121 = 1111001 110000110 = 390

5. Create a signed left shift (<<) for the following:


77 = 1001101
77 << 3 = 1001101000 = 616
77 << 5 = 100110100000 = 2464
77 << 6 = 1001101000000 = 4928

Alternative Method:
77 << 3 = 77+77= 154+154 = 308+ 308 = 616
77 << 5 = 77+77= 154+154 = 308+ 308 = 616 + 616 = 1232 + 1232 = 2464
77 << 6 = 77+77= 154+154 = 308+ 308 = 616 + 616 = 1232 + 1232 = 2464 + 2464 = 4928

6. Create a signed right shift (>>) for the following:


25 = 11001
25 >> 3 = 00011001 = 3
25 >> 4 = 000011001 = 1
25 >> 6 = 00000011001 = 0
SOLUTIONS:

You might also like