Thread: Bitwise operator question

  1. #1
    Registered User
    Join Date
    Oct 2010

    Bitwise operator question

    Basically i have taken 8 bytes and used their lsb's to hide the digits of my one byte.

    e.g 11100011 10011010 01010101 10000000 1111111 00001111 11110000 10101010

    byte i want to hide: 10010001 after my operation:

    		b1 = b1&0xfe;
    		b1 = b1 |((b0>>i)&1);
    the above 8 bytes should have lsb's like this:

    11100011 10011010 0101010(0) 10000000 1111111 0000111(0) 11110000 1010101(1)

    the (..) indicate that the lsb was changed.

    basically what i am supposed to be doing and that is what i believe i am doing is taking the lsb of each byte and replace it with the bits of my byte. If bit in position is same as my bit that i want to hide than do nothing if its 0 and my bit to hide is 1 than change the zero to 1 if its 1 and my bit to hide is 0 change the lsb to 0.
    Once i am done "hiding" my byte into lsb's of eight other bytes i need to extract the lsb's of the eight bytes out to form my original byte again.

    Can any one assist me with this and tell me how i can do that?

    thanks for your help

  2. #2
    and the Hat of Guessing tabstop's Avatar
    Join Date
    Nov 2007
    To extract? Why not do b1&1, then shift it into place?

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. C Bitwise Operation..
    By ahmedBanihammad in forum C Programming
    Replies: 4
    Last Post: 10-31-2010, 09:11 AM
  2. Bitwise Questions
    By someprogr in forum C Programming
    Replies: 8
    Last Post: 12-14-2008, 06:45 PM
  3. bitwise operations with double
    By henry_kay in forum C Programming
    Replies: 2
    Last Post: 10-03-2007, 04:57 AM
  4. C bitwise operator exercise - more like newb killer
    By shdwsclan in forum C Programming
    Replies: 3
    Last Post: 02-22-2006, 07:02 AM
  5. Characters into bitwise ints
    By Code Zer0 in forum C++ Programming
    Replies: 9
    Last Post: 04-24-2003, 08:34 AM