A RetroSearch Logo

Home - News ( United States | United Kingdom | Italy | Germany ) - Football scores

Search Query:

Showing content from https://developer.mozilla.org/ko/docs/Web/JavaScript/Reference/Global_Objects/Atomics/and below:

Atomics.and() - JavaScript | MDN

Atomics.and()

Baseline Widely available

Atomics.and() 정적 메서드는 배열의 지정된 위치에서 지정된 값으로 비트 연산 AND를 계산한 후 해당 위치의 이전 값을 반환합니다. 이 아토믹 연산은 수정된 값이 다시 쓰여질 때까지 다른 쓰기가 발생하지 않도록 보장합니다.

시도해 보기
// Create a SharedArrayBuffer with a size in bytes
const buffer = new SharedArrayBuffer(16);
const uint8 = new Uint8Array(buffer);
uint8[0] = 7;

// 7 (0111) AND 2 (0010) = 2 (0010)
console.log(Atomics.and(uint8, 0, 2));
// Expected output: 7

console.log(Atomics.load(uint8, 0));
// Expected output: 2
구문
Atomics.and(typedArray, index, value)
매개변수
typedArray

정수형 형식화 배열. Int8Array, Uint8Array, Int16Array, Uint16Array, Int32Array, Uint32Array, BigInt64Array, BigUint64Array 중 하나.

index

비트 연산 AND를 계산할 typedArray의 인덱스입니다.

value

비트 연산 AND와 같이 계산할 숫자입니다.

반환 값

주어진 위치(typedArray[index])의 예전 값.

예외 설명

비트 AND 연산은 a와 b가 모두 1인 경우에만 1을 산출합니다. AND 연산에 대한 진리 테이블은 다음과 같습니다.

a b a & b 0 0 0 0 1 0 1 0 0 1 1 1

예를 들어, 5 & 1의 비트 연산 AND는 0001, 10진수로 1입니다.

5  0101
1  0001
   ----
1  0001
예제 and() 사용하기
const sab = new SharedArrayBuffer(1024);
const ta = new Uint8Array(sab);
ta[0] = 5;

Atomics.and(ta, 0, 1); // 이전 값인 5를 반환합니다
Atomics.load(ta, 0); // 1
명세서 브라우저 호환성 같이 보기

RetroSearch is an open source project built by @garambo | Open a GitHub Issue

Search and Browse the WWW like it's 1997 | Search results from DuckDuckGo

HTML: 3.2 | Encoding: UTF-8 | Version: 0.7.4