Bitwise Ops Homework: "1001 1101" Solutions

  • Thread starter Thread starter gEOdude
  • Start date Start date
  • Tags Tags
    Operations
AI Thread Summary
The discussion revolves around solving bitwise operations on the binary number "1001 1101." The first task is to mask the outer two bits, resulting in "0001 1100," while the second task requires toggling the middle four bits to produce "1010 0001." Participants emphasize the importance of attempting the problems before seeking help, as complete solutions are not provided without effort. Suggestions include using specific bitwise operators like AND and XOR to achieve the desired outputs. The conversation highlights the need for a clear understanding of bit manipulation techniques to successfully complete the homework.
gEOdude
Messages
25
Reaction score
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:
Physics news on Phys.org
gEOdude said:
But no matter what input I add I cannot get the right output.
What did you try so far?
Could you solve some part of the problem, e. g. masking or swapping only a single bit?
 
If you don't get it, you should check this out: www.vipan.com/htdocs/bitwisehelp.html
 
Last edited:
Can you do any of it?
 
I cannot do anything and that website didn't help.
 
mfb said:
What did you try so far?
Could you solve some part of the problem, e. g. masking or swapping only a single bit?
No. :cry:
 
Per the rules of this forum (https://www.physicsforums.com/threads/physics-forums-global-guidelines.414380/), we can't help you if you don't at least make an effort.
Giving Full Answers:
On helping with questions: Any and all assistance given to homework assignments or textbook style exercises should be given only after the questioner has shown some effort in solving the problem. If no attempt is made then the questioner should be asked to provide one before any assistance is given. Under no circumstances should complete solutions be provided to a questioner, whether or not an attempt has been made.
 
You should see what operator is needed first and the rest is easy. I'll make it as easy as possible.

(1001 1101) (operator) (8 digit number made up of 1s and 0s) = 0001 1100
(1001 1101) (operator) (8 digit number made up of 1s and 0s) = 1010 0001
 
Last edited:
Mark44 said:
Per the rules of this forum (https://www.physicsforums.com/threads/physics-forums-global-guidelines.414380/), we can't help you if you don't at least make an effort.
mfb said:
What did you try so far?
Could you solve some part of the problem, e. g. masking or swapping only a single bit?
gEOdude said:
You should see what operator is needed first and the rest is easy. I'll make it as easy as possible.
(1001 1101) (operator) (8 digit number made up of 1s and 0s) = 0001 1100
(1001 1101) (operator) (8 digit number made up of 1s and 0s) = 1010 0001
(1001 1101) & (0101 1110) = 0001 1100
(1001 1101) ^ (0111 1110) = 1010 0001

IS THIS RIGHT?
 
  • #10
See if it works with other inputs as well, like 11110000 for both parts. If it does not, something is wrong.
 
  • #11
mfb said:
See if it works with other inputs as well, like 11110000 for both parts. If it does not, something is wrong.
I'm pretty sure its right. Am I missing something?
 
  • #12
What is (1111 0000) & (0101 1110) and does it match (0011 000)?
What is (1111 0000) ^ (0111 1110) and does it match (1100 1100)?

Also, just a logical consideration: the outer 4 bits are always supposed to get the same effect (set to 0 in the first case, keep the same in the second case). Can something like (01[/color]01 1110[/color]) make sense, where different bits in this group are treated differently?
 

Similar threads

Back
Top