leftShift

x << y

leftShift(x, y)

Try it yourself:


leftShift(): Shifting Integer Bits Left

leftShift() shifts an integer’s binary bits left by a specified count. For nonnegative integer arithmetic, shifting left by n generally multiplies by 2ⁿ, provided no fixed-width overflow rule changes the representation.

Bit-level caveats

Use integer operands and a nonnegative shift count. Bitwise operations operate on binary representations, not decimal digits. Compare it with rightArithShift() and rightLogShift(), which have different sign behavior.

Use bitAnd() to test flags and bitOr() to combine them. Confirm your target integer range before shifting large values, because precision and sign rules affect results.

Try Left Shift in Calcul.io

Start with one of the editable examples above, then replace its arguments with your own values. Keeping the function on a separate calculator line makes the input and result easy to compare. For a longer workflow, assign the result to a variable or reference that line in the next expression.

Check the shown signature before adding optional arguments, and use the related-function links to compare operations with similar purposes.

All functions