-3

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

#define  x (10 * (1<<12));
Grijesh Chauhan
  • 57,103
  • 20
  • 141
  • 208
Sara
  • 2,308
  • 11
  • 50
  • 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
  • 10,151
  • 6
  • 39
  • 52
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,405
  • 4
  • 26
  • 43