What is a Left Shift?
What is a Left Shift?
When shifting left, the most significant bit is lost, and a 0 bit is inserted on the other end. The left shift operator is usually written as "<<". A single left shift multiplies a binary number by 2.
// 2 bit shifted left by 1 space = 4
0010 << 1 -> 0100 = 4
// 2 bit shifted left by 2 spaces = 8
0010 << 2 -> 1000 = 8