Click here to Skip to main content
15,889,654 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
I have come accross the MSDN Operator (C# Reference).
But i am not able to get the working of this. When the operator is shifting a digit to left by 4
as in this example . How it is possible that it produces output of 16000 ? Thanks.

Source : http://msdn.microsoft.com/en-us/library/ayt2kcfb(v=vs.90).aspx[^]

class MainClass9
{
static void Main()
{
int a = 1000;
a <<= 4;
Console.WriteLine(a);
}
}
/*
Output:
16000
*/
Posted
Updated 10-Sep-14 20:00pm
v2

1 solution

Because left shifting a binary number multiplies it by two, e.g.
C
00000101B (=5) left shifted becomes 00001010B (=10)

Hence, left shifting a number four times multiplies it by 16.
 
Share this answer
 
Comments
Rambo_Raja 11-Sep-14 2:27am    
Thank you.
CPallini 11-Sep-14 9:59am    
You are welcome.

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900