From 988e86fd3ad30188de78ee861beaff662221574e Mon Sep 17 00:00:00 2001 From: professorxin <1252778220@qq.com> Date: Tue, 17 Sep 2019 13:46:39 +0800 Subject: [PATCH] =?UTF-8?q?=E4=BF=AE=E6=AD=A3Leetcode=E9=A2=98=E8=A7=A3?= =?UTF-8?q?=E7=9A=84=E4=BD=8D=E8=BF=90=E7=AE=97=E5=9F=BA=E6=9C=AC=E5=8E=9F?= =?UTF-8?q?=E7=90=86=E9=83=A8=E5=88=86=E7=9A=84=E6=8F=8F=E8=BF=B0=E9=94=99?= =?UTF-8?q?=E8=AF=AF?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- ...230\350\247\243 - \344\275\215\350\277\220\347\256\227.md" | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git "a/notes/Leetcode \351\242\230\350\247\243 - \344\275\215\350\277\220\347\256\227.md" "b/notes/Leetcode \351\242\230\350\247\243 - \344\275\215\350\277\220\347\256\227.md" index d4c659b7..a89999ad 100644 --- "a/notes/Leetcode \351\242\230\350\247\243 - \344\275\215\350\277\220\347\256\227.md" +++ "b/notes/Leetcode \351\242\230\350\247\243 - \344\275\215\350\277\220\347\256\227.md" @@ -47,9 +47,9 @@ x ^ x = 0 x & x = x x | x = x 要得到只有第 i 位为 1 的 mask,将 1 向左移动 i-1 位即可,1<<(i-1) 。例如 1<<4 得到只有第 5 位为 1 的 mask :00010000。 -要得到 1 到 i 位为 1 的 mask,1<<(i+1)-1 即可,例如将 1<<(4+1)-1 = 00010000-1 = 00001111。 +要得到 1 到 i 位为 1 的 mask,(1<<i)-1 即可,例如将 (1<<4)-1 = 00010000-1 = 00001111。 -要得到 1 到 i 位为 0 的 mask,只需将 1 到 i 位为 1 的 mask 取反,即 \~(1<<(i+1)-1)。 +要得到 1 到 i 位为 0 的 mask,只需将 1 到 i 位为 1 的 mask 取反,即 \~((1<<i)-1)。 **Java 中的位操作** -- GitLab