Skip to content

Commit

Permalink
Update java-basic-questions-01.md
Browse files Browse the repository at this point in the history
讲解位移运算时,举的例子有问题
  • Loading branch information
Horstson committed Feb 1, 2023
1 parent c40444e commit b9a3f99
Showing 1 changed file with 1 addition and 1 deletion.
2 changes: 1 addition & 1 deletion docs/java/basis/java-basic-questions-01.md
Original file line number Diff line number Diff line change
Expand Up @@ -263,7 +263,7 @@ Java 中有三种移位运算符:

当 int 类型左移/右移位数大于等于 32 位操作时,会先求余(%)后再进行左移/右移操作。也就是说左移/右移 32 位相当于不进行移位操作(32%32=0),左移/右移 42 位相当于左移/右移 10 位(42%32=10)。当 long 类型进行左移/右移操作时,由于 long 对应的二进制是 64 位,因此求余操作的基数也变成了 64。

也就是说:`x<<42`等同于`x<<10``x>>42`等同于`x>>10`,``x >>>42`等同于`i4 >>> 10`。
也就是说:`x<<42`等同于`x<<10``x>>42`等同于`x>>10``x >>>42`等同于`x >>> 10`

**左移运算符代码示例**

Expand Down

0 comments on commit b9a3f99

Please sign in to comment.