ShiftLeft()

Summary

Performs a left arithmetic shift of the bits in an integer.

Syntax

int = ShiftLeft(integer int1, integer shift)

Argument Contents
int1 An integer
shift Number of bits to shift left, from 1 to 32; a negative value will shift right

Returns

An integer with an arithmetic shift of the bits the specified number of places to the left.

Notes

  • Bits are dropped from the left end, and new bits on the right are set to 0.

  • The sign bit can change if a different value moves into the sign (leftmost) bit.

  • Until the sign bit is changed, ShiftLeft() is the equivalent of multiplying by powers of 2.

Examples

int = ShiftLeft(15, 1) // int = 30: in binary, 1111 becomes 11110
int = ShiftLeft(1073741824, 1) // int = -2147483648: leftmost numeric bit moved to sign bit

See Also

Function Summary
BitwiseAnd() Computes the bitwise AND of two integers
BitwiseNot() Computes the bitwise NOT of an integer
BitwiseOr() Computes the bitwise OR of two integers
BitwiseXor() Computes the bitwise exclusive OR of an integer
ShiftRight() Does a right arithmetic shift of the bits in an integer