Thread: Bit-Wise expresions

  1. #1
    Registered User
    Join Date
    Feb 2013

    Bit-Wise expresions


    Could you please refresh my memory and explane those arguments ?

    1. y = x & ~(1<<n) ( x=2 ,n=3)

    2. y = ~x & (x+1)

    3. a<<=1 ( a is define as int )

    4. b>>=1 ( b is define as int )

    Thanks in advanced

  2. #2
    Lurking whiteflags's Avatar
    Join Date
    Apr 2006
    United States
    & means mask, or turn one bit on in the result if the same bit is on for both arguments.
    ~ means flip the bits
    >>= means shift this value to the right N places and assign the new value. In other words, the value should get smaller as you move left by 2^N
    <<= means shift this value to the left N places and assign the new value. In other words, the value should get larger as you move right by 2^N
    Last edited by whiteflags; 07-07-2014 at 04:09 AM.

  3. #3
    Registered User
    Join Date
    Jun 2005
    Sorry, but homework is most often the settings where folks are asked to explain expressions like these. That puts you at odds with the site's homework policy, here.

    Try giving the best explanation you can - yourself (i.e. show more effort than just copying questions to a forum). If you get things wrong, folks will be more inclined to help.
    Right 98% of the time, and don't care about the other 3%.

    If I seem grumpy or unhelpful in reply to you, or tell you you need to demonstrate more effort before you can expect help, it is likely you deserve it. Suck it up, Buttercup, and read this, this, and this before posting again.

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. Replies: 12
    Last Post: 11-25-2012, 12:56 AM
  2. Bit Wise Functions
    By Prediluted in forum C Programming
    Replies: 4
    Last Post: 06-15-2011, 01:03 AM
  3. What do i need network wise?
    By Logikal in forum Tech Board
    Replies: 1
    Last Post: 03-17-2010, 03:00 AM
  4. graphics please help i'll cry other wise
    By super_monkey in forum Game Programming
    Replies: 4
    Last Post: 11-14-2001, 01:45 AM