Bitwise Ops Homework: "1001 1101" Solutions

  • Thread starter gEOdude
  • Start date
  • Tags
    Operations
In summary: 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 (0101 1110) make sense, where different bits in this group are treated differently?Yes, (0101 1110) makes sense.
  • #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:
Physics news on Phys.org
  • #2
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?
 
  • #3
If you don't get it, you should check this out: www.vipan.com/htdocs/bitwisehelp.html
 
Last edited:
  • #4
Can you do any of it?
 
  • #5
I cannot do anything and that website didn't help.
 
  • #6
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:
 
  • #7
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.
 
  • #8
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:
  • #9
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 (0101 1110) make sense, where different bits in this group are treated differently?
 

1. What are bitwise operations?

Bitwise operations are operations that are performed on individual bits of binary numbers. They include operations such as AND, OR, XOR, and NOT.

2. How do I represent binary numbers?

Binary numbers are represented using only two digits, 0 and 1. Each digit represents a bit, and the value of the number is calculated by adding up the values of each bit.

3. What is the binary number "1001 1101" in decimal?

The binary number "1001 1101" is equivalent to the decimal number 157.

4. What is the solution for "1001 1101 AND 0101 0101"?

The solution for "1001 1101 AND 0101 0101" is "0001 0101". This is because the AND operation only results in a 1 when both bits are 1, otherwise the result is 0.

5. How can bitwise operations be useful in computer programming?

Bitwise operations can be useful in computer programming for tasks such as data compression, encryption, and optimizing memory usage. They can also be used for tasks such as checking for specific bits in a binary number or manipulating individual bits of a number.

Similar threads

  • Programming and Computer Science
Replies
4
Views
2K
  • Engineering and Comp Sci Homework Help
Replies
2
Views
10K
  • Engineering and Comp Sci Homework Help
Replies
1
Views
1K
  • Engineering and Comp Sci Homework Help
Replies
4
Views
1K
  • Engineering and Comp Sci Homework Help
Replies
2
Views
2K
  • Engineering and Comp Sci Homework Help
Replies
17
Views
5K
  • Engineering and Comp Sci Homework Help
Replies
5
Views
2K
  • Engineering and Comp Sci Homework Help
Replies
1
Views
972
  • Engineering and Comp Sci Homework Help
Replies
2
Views
2K
  • Engineering and Comp Sci Homework Help
Replies
1
Views
1K
Back
Top