Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • World
  • Users
  • Groups
Skins
  • Light
  • Cerulean
  • Cosmo
  • Flatly
  • Journal
  • Litera
  • Lumen
  • Lux
  • Materia
  • Minty
  • Morph
  • Pulse
  • Sandstone
  • Simplex
  • Sketchy
  • Spacelab
  • United
  • Yeti
  • Zephyr
  • Dark
  • Cyborg
  • Darkly
  • Quartz
  • Slate
  • Solar
  • Superhero
  • Vapor

  • Default (No Skin)
  • No Skin
Collapse
Code Project
  1. Home
  2. General Programming
  3. C / C++ / MFC
  4. bitwise left shift and sight shift Operators << , >>

bitwise left shift and sight shift Operators << , >>

Scheduled Pinned Locked Moved C / C++ / MFC
tutorial
3 Posts 2 Posters 0 Views 1 Watching
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • A Offline
    A Offline
    Ahmad
    wrote on last edited by
    #1

    HI ALL :) My qustion about bitwise left shift and sight shift Operators << , >> I don't understand what it does,I searched in MSDN i found that : The bitwise shift operators shift their first operand left (<<) or right (>>) by the number of positions the second operand specifies. and then give me this example : // Example of the bitwise right shift operator int nNumA=8; // beginning value is 8 nNumA >> 2; // ending value is 2 what this does the (nNumA) stil has the value (8) Can you tell me what the << , >> do, and when I use it. THANK YOU AHMAD ALWASHALI

    L 1 Reply Last reply
    0
    • A Ahmad

      HI ALL :) My qustion about bitwise left shift and sight shift Operators << , >> I don't understand what it does,I searched in MSDN i found that : The bitwise shift operators shift their first operand left (<<) or right (>>) by the number of positions the second operand specifies. and then give me this example : // Example of the bitwise right shift operator int nNumA=8; // beginning value is 8 nNumA >> 2; // ending value is 2 what this does the (nNumA) stil has the value (8) Can you tell me what the << , >> do, and when I use it. THANK YOU AHMAD ALWASHALI

      L Offline
      L Offline
      Lost User
      wrote on last edited by
      #2

      Ahmad the bitwise operators move the bits in a variable left or right the number of positions requested. Take the following code snippet for example.

      void main()
      {
      int nNumber = 8; // Binary value 00001000 Decimal 8

      nNumber >> 2; // Binary value 00000010 Decimal 2
      }

      If you move the bits set to 1 too far to the left or right they just drop off the end and are lost. Hope that helps. Michael Martin Pegasystems Pty Ltd Australia martm@pegasystems.com +61 413-004-018

      A 1 Reply Last reply
      0
      • L Lost User

        Ahmad the bitwise operators move the bits in a variable left or right the number of positions requested. Take the following code snippet for example.

        void main()
        {
        int nNumber = 8; // Binary value 00001000 Decimal 8

        nNumber >> 2; // Binary value 00000010 Decimal 2
        }

        If you move the bits set to 1 too far to the left or right they just drop off the end and are lost. Hope that helps. Michael Martin Pegasystems Pty Ltd Australia martm@pegasystems.com +61 413-004-018

        A Offline
        A Offline
        Ahmad
        wrote on last edited by
        #3

        Thank you very much AHMAD ALWASHALI

        1 Reply Last reply
        0
        Reply
        • Reply as topic
        Log in to reply
        • Oldest to Newest
        • Newest to Oldest
        • Most Votes


        • Login

        • Don't have an account? Register

        • Login or register to search.
        • First post
          Last post
        0
        • Categories
        • Recent
        • Tags
        • Popular
        • World
        • Users
        • Groups