From 33058f2b292b3a581333bdfb21b8f671898c5060 Mon Sep 17 00:00:00 2001 From: Peter Bengtsson Date: Tue, 8 Dec 2020 14:40:17 -0500 Subject: initial commit --- .../global_objects/atomics/and/index.html | 131 +++++++++++++++++++++ 1 file changed, 131 insertions(+) create mode 100644 files/ja/web/javascript/reference/global_objects/atomics/and/index.html (limited to 'files/ja/web/javascript/reference/global_objects/atomics/and/index.html') diff --git a/files/ja/web/javascript/reference/global_objects/atomics/and/index.html b/files/ja/web/javascript/reference/global_objects/atomics/and/index.html new file mode 100644 index 0000000000..6a586a73f1 --- /dev/null +++ b/files/ja/web/javascript/reference/global_objects/atomics/and/index.html @@ -0,0 +1,131 @@ +--- +title: Atomics.and() +slug: Web/JavaScript/Reference/Global_Objects/Atomics/and +tags: + - Atomics + - JavaScript + - Method + - Shared Memory + - メソッド + - 共有メモリ +translation_of: Web/JavaScript/Reference/Global_Objects/Atomics/and +--- +
{{JSRef}}
+ +

静的な Atomics.and() メソッドは、配列内の指定した位置の値に指定した値でビット単位の AND を計算し、その位置の古い値を返します。これは不可分操作で、修正された値が書き戻されるまで、他の書き込みが起こらないことを保証します。

+ +
{{EmbedInteractiveExample("pages/js/atomics-and.html")}}
+ + + +

構文

+ +
Atomics.and(typedArray, index, value)
+
+ +

引数

+ +
+
typedArray
+
共有整数型付き配列です。 {{jsxref("Int8Array")}}, {{jsxref("Uint8Array")}}, {{jsxref("Int16Array")}}, {{jsxref("Uint16Array")}}, {{jsxref("Int32Array")}}, {{jsxref("Uint32Array")}} の何れかです。
+
index
+
typedArray でビット単位の AND を計s名する位置です。
+
value
+
ビット単位の AND を取る数値です。
+
+ +

返値

+ +

指定された位置にあった古い値です (typedArray[index])。

+ +

例外

+ + + +

解説

+ +

ビット単位の AND 操作は、 ab の両方が 1 であった場合のみ 1 を生成します。 AND 操作の真理値表を示します。

+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
aba & b
000
010
100
111
+ +

例えば、ビット単位の AND を 5 & 1 で行うと、結果は 0001 すなわち10進数で1となります。

+ +
5  0101
+1  0001
+   ----
+1  0001
+ +

+ +

add() の使用

+ +
const sab = new SharedArrayBuffer(1024);
+const ta = new Uint8Array(sab);
+ta[0] = 5;
+
+Atomics.and(ta, 0, 1); // returns 0, the old value
+Atomics.load(ta, 0);  // 1
+
+ +

仕様書

+ + + + + + + + + + + + +
仕様書
{{SpecName('ESDraft', '#sec-atomics.and', 'Atomics.and')}}
+ +

ブラウザーの互換性

+ + + +

{{Compat("javascript.builtins.Atomics.and")}}

+ +

関連情報

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