bitwise left shift and sight shift Operators << , >>
-
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
-
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
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 8nNumber >> 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
-
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 8nNumber >> 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