From 310fd066e91f454b990372ffa30e803cc8120975 Mon Sep 17 00:00:00 2001 From: Florian Merz Date: Thu, 11 Feb 2021 12:56:40 +0100 Subject: unslug zh-cn: move --- .../index.html" | 106 --------------------- 1 file changed, 106 deletions(-) delete mode 100644 "files/zh-cn/web/javascript/reference/operators/\346\214\211\344\275\215\344\270\216/index.html" (limited to 'files/zh-cn/web/javascript/reference/operators/按位与/index.html') diff --git "a/files/zh-cn/web/javascript/reference/operators/\346\214\211\344\275\215\344\270\216/index.html" "b/files/zh-cn/web/javascript/reference/operators/\346\214\211\344\275\215\344\270\216/index.html" deleted file mode 100644 index 20eece2691..0000000000 --- "a/files/zh-cn/web/javascript/reference/operators/\346\214\211\344\275\215\344\270\216/index.html" +++ /dev/null @@ -1,106 +0,0 @@ ---- -title: 按位与 (&) -slug: Web/JavaScript/Reference/Operators/按位与 -translation_of: Web/JavaScript/Reference/Operators/Bitwise_AND ---- -
{{jsSidebar("Operators")}}
- -

按位与运算符 (&) 在每个位上返回 1 ,这两个操作数对应的位都是 1.

- -
{{EmbedInteractiveExample("pages/js/expressions-bitwise-and.html")}}
- - - -

语法

- -
a & b
-
- -

描述

- -

操作数被转换为32位整数,并由一系列位(0和1)表示。 超过32位的数字将丢弃其最高有效位。 例如,以下大于32位的整数将被转换为32位整数:

- -
Before: 11100110111110100000000000000110000000000001
-After:              10100000000000000110000000000001
- -

第一个操作数中的每个位都与第二个操作数中的相应位配对:第一位到第一位,第二位到第二位,依此类推。

- -

将运算符应用于每对位,然后按位构造结果。

- -

与运算的真值表:

- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
aba AND b
000
010
100
111
- -
.    9 (base 10) = 00000000000000000000000000001001 (base 2)
-    14 (base 10) = 00000000000000000000000000001110 (base 2)
-                   --------------------------------
-14 & 9 (base 10) = 00000000000000000000000000001000 (base 2) = 8 (base 10)
-
- -

将任何数字x0进行按位与运算将得出0

- -

示例

- -

使用按位与

- -
// 5: 00000000000000000000000000000101
-// 2: 00000000000000000000000000000010
-5 & 2; // 0
- -

规范说明

- - - - - - - - - - - - -
Specification
{{SpecName('ESDraft', '#prod-BitwiseANDExpression', 'Bitwise AND expression')}}
- -

浏览器兼容性

- - - -

{{Compat("javascript.operators.bitwise_and")}}

- -

参阅

- - -- cgit v1.2.3-54-g00ecf