Right shift

Classification Images
Name:
Right shift

Symbol:
>>
Appearance:

Appearance.
*Group:
Bitwise operators

CannyLab version:
from 0.6b
Icon:

Icon.
Inputs
Input Value
Value: Integer
Shift, bits: Integer
Outputs
Output Value
Result: Integer

General description

Logical shift to the Right. Set the output result as the logical right shift in binary representation of the input “Value”, the number of bits to shift specified by the input “Shift, bit”.бит».

In other words, the result is equivalent to the result of copying each bit in binary representation of input “value” to its right position, to the number of times specified by the value of the input “Shift, bit”. Thus, the most significant (left-most) bit in the binary representation of the results each time gets a “0”.

For example:

Value   =   22  =   0x0016  =   0b0000000000010110
Shift, bits =   2   
Result  =   5   =   0x0005  =   0b0000000000000101

Features

Результат логического сдвига значения вправо:

  • for one bit — equivalent to the results of its integer division by 2;

  • for two bits — equivalent to the results of its integer division by 4;

  • for three bits — equivalent to the results of its integer division by 8;

etc.

Examples

Decimal representation:

Example 1.

Binary representation:

Example 2.

SEE ALSO