- #1
gEOdude
- 25
- 0
Homework Statement
Given an 8-bit binary number “1001 1101”:
1)Turn off the 2 bits (masking bits to 0) on each side, and leave the middle 4 alone. The output should be “0001 1100”.
Given an 8-bit binary number “1001 1101”:
2) Toggle the values of the middle 4 bits (the opposite of what it currently is), and leave the 2 bits on each side untouched. The output should be “1010 0001”.
Homework Equations
None
The Attempt at a Solution
Its to confusing. I just want some help on how to do it. I understand the basics that To reset (i.e.make 0) a bit in a byte , I have to AND it with a mask of all 1’s except the bit to reset! AND ALSO the toggle (i.e. change from 0 to 1, or 1 to 0).
But no matter what input I add I cannot get the right output. Might as well be guessing.
Mod note: Changed "Giving" in the two problems to "Given".
Last edited by a moderator: