左移
(重定向自逻辑左移)
左移 | |
---|---|
术语名称 | 左移 |
英语名称 | left shift |
别名 | 按位左移, 算术左移, arithmetic left shift, 逻辑左移, logical left shift |
左移(left shift)是位运算的一种,指将数据的全部位向高位移动并在低位补 0 的运算。算术左移(arithmetic left shift)和逻辑左移(logical left shift)指同一运算。
定义
左移 | |
---|---|
运算名称 | 左移 |
运算符号 | |
Latex | |
运算对象 | 二进制串, 自然数 |
运算元数 | 2 |
运算结果 | 二进制串 |
定义域 | [math]\displaystyle{ \mathbb{B}^n \times \mathbb{N} }[/math] |
陪域 | [math]\displaystyle{ \mathbb{B}^n }[/math] |
对二进制串 [math]\displaystyle{ b_1 b_2 \cdots b_m }[/math] 和自然数 [math]\displaystyle{ n }[/math] ,得到二进制串 [math]\displaystyle{ b_{n+1} b_{n+2} \dots b_m \underbrace{ 0 0 \cdots 0}_{n 个 0} }[/math] ,称这种运算为左移(left shift),得到的二进制串称为原二进制串左移 [math]\displaystyle{ n }[/math] 位(shifted left by [math]\displaystyle{ n }[/math] (bits))的结果。
位运算 | ||
---|---|---|
按位运算 | 按位运算 | 按位取反、按位与、按位或、按位异或 |
特殊情况 | 掩码、位设置、位清除、位反转 | |
移位运算 | 算术移位 | 算术左移、算术右移 |
逻辑移位 | 逻辑左移、逻辑右移 | |
循环移位 | 循环左移、循环右移 |