Shl, Shr, Asr

Shl, Shr: Logic bit shift to the left (Shl) or right (Shr). For integer data types, e.g. Byte, word, etc.: Shifting the bits by one position to the left leads to a multiplication by 2, shifting the bits by one position to the right leads to divide by 2. Asr: arithmetical shift-right. for signed integer data types such as Int8, Int16, integer, etc.: .

Syntax:

  • Shl Variable, Bits
  • Shr Variable, Bits
  • Asr Variable, Bits

For variable, only a integer variable from working memory is permitted. Alternatively, the bit shift operators "<<" or ">>" can also be used for unsigned integer variables.

Example:

  dim a as word
  a=0b0000000100000000
  Shl a, 4  ' shift 4 bits to the left, result: 0b0001000000000000

See also: Add, Sub, Mul, Div, Bitshift-Operators "<<" bzw. ">>"