Left shifts the bits of an expression.

expression1 |

# Arguments

*expression1*-
Any numeric expression.

*expression2*-
Any numeric expression.

# Remarks

The **<<** operator shifts the bits of *expression1* left by the number of bits specified in *expression2*. The data type of *expression1* determines the data type returned by this operator.

The **<<** operator masks *expression2* to avoid shifting *expression1* by too much. Otherwise, if the shift amount exceeded the number of bits in the data type of *expression1*, all the original bits would be shifted away to give a trivial result. To ensure that each shift leaves at least one of the original bits, the shift operators use the following formula to calculate the actual shift amount: mask *expression2* (using the bitwise AND operator) with one less than the number of bits in *expression1*.

# Example

For example:

В | Copy Code |
---|---|

var temp temp = 14 |

The variable *temp* has a value of 56 because 14 (00001110 in binary) shifted left two bits equals 56 (00111000 in binary).

To illustrate how the masking works, consider the following example.

В | Copy Code |
---|---|

var x : byte = 15; // A byte stores 8 bits. // The bits stored in x are 00001111 var y : byte = x |