Facebook Page
Twitter
RSS
+ Reply to Thread
Results 1 to 5 of 5

Thread: Bit Operations

  1. MHB Apprentice

    Status
    Offline
    Join Date
    Apr 2015
    Posts
    12
    Thanks
    7 times
    Thanked
    0 times
    #1
    Hey Guys, can i have a hand with this question. I just want to know if what I did was right.

    Bit masking has a task. They are used in order to access specific bits in a byte of data.

    1) Using the 8-bit binary number 1001 1101:
    Turn off the 2 bits (masking bits to 0) on each side, and then leave the middle 4 alone.The output should be achieved should be "0001 1100.

    2) Using the 8-bit binary number 1001 1101:
    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 achieved should be"10100001.



    Answer
    1) (1001 1101) & (0101 1110) = 0001 1100
    2) (1001 1101) ^ (0111 1110) = 1010 0001

  2. MHB Master
    MHB Site Helper
    MHB Math Scholar

    Status
    Offline
    Join Date
    Jan 2012
    Posts
    2,171
    Thanks
    507 times
    Thanked
    4,050 times
    Thank/Post
    1.865
    Awards
    MHB Chat Room Award (2016)  

MHB Humor Award (2016)  

MHB Discrete Mathematics Award (2016)  

MHB Best Ideas Award (2015)  

MHB Discrete Mathematics Award (2015)
    #2
    Quote Originally Posted by HELPMEHELPME View Post
    1) Using the 8-bit binary number 1001 1101:
    Turn off the 2 bits (masking bits to 0) on each side, and then leave the middle 4
    alone.
    Quote Originally Posted by HELPMEHELPME View Post
    Toggle the values of the middle 4 bits (the opposite of what it currently is), and leave the 2 bits on each side untouched.
    Why do these quotes talk about the middle 4 bits and the 2 bits on each side, that is, 6 bits in total, when the input number consists of 8 bits?

  3. MHB Apprentice

    Status
    Offline
    Join Date
    Apr 2015
    Posts
    12
    Thanks
    7 times
    Thanked
    0 times
    #3 Thread Author
    Im not sure, its how my teacher wrote the problem. Is there something wrong with it?

  4. MHB Seeker
    MHB Global Moderator
    MHB Math Scholar
    I like Serena's Avatar
    Status
    Offline
    Join Date
    Mar 2012
    Location
    Netherlands
    Posts
    5,917
    Thanks
    3,982 times
    Thanked
    11,212 times
    Thank/Post
    1.895
    Awards
    MHB Model Helper Award (2016)  

MHB Best Ideas (2016)  

MHB LaTeX Award (2016)  

MHB Calculus Award (2014)  

MHB Discrete Mathematics Award (Jul-Dec 2013)
    #4
    Quote Originally Posted by HELPMEHELPME View Post
    Bit masking has a task. They are used in order to access specific bits in a byte of data.

    1) Using the 8-bit binary number 1001 1101:
    Turn off the 2 bits (masking bits to 0) on each side, and then leave the middle 4 alone.The output should be achieved should be "0001 1100.
    The mask that masks out 2 bits on each side is
    0011 1100
    .
    Using this mask we can do:
    1001 1101 &
    0011 1100
    = 0001 1100

    Quote Quote:
    2) Using the 8-bit binary number 1001 1101:
    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 achieved should be"10100001.
    Using the same mask:
    1001 1101 ^
    0011 1100
    = 1010 0001


    Quote Quote:
    Answer
    2) (1001 1101) ^ (0111 1110) = 1010 0001
    I'm afraid the xor operator is not evaluated properly here.

    Quote Originally Posted by Evgeny.Makarov View Post
    Why do these quotes talk about the middle 4 bits and the 2 bits on each side, that is, 6 bits in total, when the input number consists of 8 bits?
    Quote Originally Posted by HELPMEHELPME View Post
    Im not sure, its how my teacher wrote the problem. Is there something wrong with it?
    No.
    2 bits on each side means 2 bits to the left and 2 bits to the right, for 2+4+2=8 bits in total.

  5. MHB Master
    MHB Site Helper
    MHB Math Scholar

    Status
    Offline
    Join Date
    Jan 2012
    Posts
    2,171
    Thanks
    507 times
    Thanked
    4,050 times
    Thank/Post
    1.865
    Awards
    MHB Chat Room Award (2016)  

MHB Humor Award (2016)  

MHB Discrete Mathematics Award (2016)  

MHB Best Ideas Award (2015)  

MHB Discrete Mathematics Award (2015)
    #5
    Quote Originally Posted by I like Serena View Post
    2 bits on each side means 2 bits to the left and 2 bits to the right, for 2+4+2=8 bits in total.
    Of course. Sorry about my misunderstanding.

Similar Threads

  1. Prove that the operations are well-defined
    By evinda in forum Discrete Mathematics, Set Theory, and Logic
    Replies: 0
    Last Post: January 22nd, 2015, 14:19
  2. Order of Operations
    By Marvin Kalngan in forum Pre-Algebra and Algebra
    Replies: 1
    Last Post: April 19th, 2014, 21:48
  3. operations on sets
    By bergausstein in forum Discrete Mathematics, Set Theory, and Logic
    Replies: 1
    Last Post: August 5th, 2013, 09:56
  4. Operations on sets
    By bergausstein in forum Pre-Algebra and Algebra
    Replies: 2
    Last Post: August 3rd, 2013, 07:04
  5. Operations on sets II
    By bergausstein in forum Pre-Algebra and Algebra
    Replies: 1
    Last Post: August 2nd, 2013, 21:54

Tags for this Thread

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
Math Help Boards