Baseline Widely available
Atomics.xor()
ì ì ë©ìëë ë°°ì´ìì 주ì´ì§ ìì¹ì 주ì´ì§ ê°ì¼ë¡ XOR ë¹í¸ ì°ì°ì ìííê³ í´ë¹ í¬ì§ì
ì 기존 ê°ì ë°íí©ëë¤. ì´ ìí 믹 ì°ì°ì ìì ë ê°ì´ ì°ì´ê¸° ì ê¹ì§ ë¤ë¥¸ ì°ê¸° ì°ì°ì´ ì¼ì´ëì§ ììì ë³´ì¥í©ëë¤.
// Create a SharedArrayBuffer with a size in bytes
const buffer = new SharedArrayBuffer(16);
const uint8 = new Uint8Array(buffer);
uint8[0] = 7;
// 7 (0111) XOR 2 (0010) = 5 (0101)
console.log(Atomics.xor(uint8, 0, 2));
// Expected output: 7
console.log(Atomics.load(uint8, 0));
// Expected output: 5
구문
Atomics.xor(typedArray, index, value)
ë§¤ê° ë³ì
typedArray
ì ìí íìí ë°°ì´. Int8Array
, Uint8Array
, Int16Array
, Uint16Array
, Int32Array
, Uint32Array
, BigInt64Array
, BigUint64Array
ì¤ íë.
index
ë¹í¸ ì°ì° XOR를 ê³ì°í typedArray
ì ì¸ë±ì¤ì
ëë¤.
value
ë¹í¸ ì°ì° XORì ê°ì´ ê³ì°í ì«ìì ëë¤.
주ì´ì§ ìì¹(typedArray[index]
)ì ìì ê°.
typedArray
ê° íì©ë ì ìíì´ ìë ê²½ì° TypeError
ê° ë°ìí©ëë¤.index
ê° typedArray
ì ë²ì를 ë²ì´ë ê²½ì° RangeError
ê° ë°ìí©ëë¤.ë¹í¸ ì°ì° XORì a
ì b
ì´ ë¤ë¥´ë©´ 1ì ì°ì¶í©ëë¤. XOR ì°ì°ì ëí ì§ë¦¬íë ë¤ìê³¼ ê°ìµëë¤.
a
b
a ^ b
0 0 0 0 1 1 1 0 1 1 1 0
ì를 ë¤ì´, 5 ^ 1
ì ë¹í¸ ì°ì° XORì ê°ì 0100
ì´ë©° 10ì§ìë¡ 4ì
ëë¤.
5 0101 1 0001 ---- 4 0100ìì xor ì¬ì©í기
const sab = new SharedArrayBuffer(1024);
const ta = new Uint8Array(sab);
ta[0] = 5;
Atomics.xor(ta, 0, 1); // ì´ì ê°ì¸ 5를 ë°íí©ëë¤
Atomics.load(ta, 0); // 4
ëª
ì¸ ë¸ë¼ì°ì í¸íì± ê°ì´ 보기
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