-3

I am wondering to know What is the meaning of operator << in

#define  x (10 * (1<<12));
Grijesh Chauhan
  • 55,177
  • 19
  • 133
  • 197
Sara
  • 2,178
  • 10
  • 47
  • 76

2 Answers2

1

It's the bitshift operator. << is shift left, >> is shift right. 1 << 12 means shift the value (the int '1') 12 bits to the left.

'1' is 00000000 00000000 00000000 00000001 in binary, if it's a 32 bit integer. To shift it left 12 places, changes it to: 00000000 00000000 00010000 00000000

If you were to shift 5 << 8, '5' is 101 in binary, so it'll shift:

00000000 00000000 00000000 00000101

Into:

00000000 00000000 00000101 00000000

See this question for details on the other bitwise operators.

Community
  • 1
  • 1
Jamin Grey
  • 9,613
  • 6
  • 38
  • 50
1

It means 1 shifted 12 bits to the left. You can find thisand more at a quick reference at:

http://www.sourcepole.ch/sources/programming/cpp/cppqref.html

Bardicer
  • 1,347
  • 2
  • 27
  • 42