Files
2nd/10_Wiki/Topics/Domain_Programming/Topic_JavaScript/JavaScript_Bitwise.md
T
Antigravity Agent c24165b8bc refactor(topics): 멀티 에이전트용 지식 재편 — _Common(공통 기본기) + Domain_* 구조
에이전트 8종(대화형/프로그래머 C·S/디자이너/설계자/기획자/QA/PD/PM)에게
[공통 기본 능력 + 롤별 Specialty] 2층으로 지식을 주입하기 위한 재분류.
문서 내용·포맷은 무수정, 폴더 이동만 (6,372개 문서 수 보존 확인).

- Topic_Programming → Domain_Programming (내부 구조 보존)
- Topic_Graphic → Domain_Design
- Topic_Business → Domain_Product
- Topic_General → Domain_General
- _Common 신설: Math(구 Topic_Math_Specialty), Reasoning(구 General/From_Thinking & Reasoning),
  Reasoning_Creativity(구 General/From_창의성), Communication(Poetic_Blog_Writing + From_writing)
- 타 도메인의 From_* 폴더는 유지 (출처 표기일 뿐, 이미 도메인에 맞게 분류된 문서)
- 빈 폴더 정리 (memory/procedures)
- 에이전트→폴더 매핑은 workspace의 .astra/agent-knowledge-map.json (9개 에이전트)

Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
2026-07-11 11:05:56 +09:00

6.1 KiB

id, title, category, status, verification_status, canonical_id, aliases, duplicate_of, source_trust_level, confidence_score, created_at, updated_at, review_reason, merge_history, tags, raw_sources, applied_in, github_commit
id title category status verification_status canonical_id aliases duplicate_of source_trust_level confidence_score created_at updated_at review_reason merge_history tags raw_sources applied_in github_commit
javascript-bitwise JavaScript Bitwise Frontend draft conceptual
bitwise operators
bit manipulation
AND OR XOR
bit shift
two's complement
32-bit operations
B 0.87 2026-06-23 2026-06-23
javascript
js
web
frontend
w3schools
bitwise
operators
https://www.w3schools.com/js/js_bitwise.asp

JavaScript Bitwise

🎯 한 줄 통찰 (One-line insight)

JavaScript bitwise operators work bit-by-bit on the binary representation of numbers — even though numbers are stored as 64-bit floats, every bitwise operation is performed on 32-bit binary numbers and returns a standard number. [S1]

🧠 핵심 개념 (Core concepts)

  • Seven bitwise operators — AND (&), OR (|), XOR (^), NOT (~), zero fill left shift (<<), signed right shift (>>), and zero fill right shift (>>>). [S1]
  • 64-bit storage, 32-bit operations — JavaScript stores numbers as 64-bit floating point numbers, but all bitwise operations are performed on 32-bit binary numbers. [S1]
  • NOT and signed shift can produce negatives~5 returns -6, and -5 >> 1 returns -3, because of two's complement representation. [S1]
  • Bitwise assignment operators — shift assignments (<<=, >>=, >>>=) and bitwise assignments (&=, ^=, |=) combine the operation with assignment. [S1]
  • Base conversion via bitwise — decimal-to-binary and binary-to-decimal can be done with (dec >>> 0).toString(2) and parseInt(bin, 2).toString(10). [S1]

🧩 추출된 패턴 (Extracted patterns)

  • Per-bit combination&, |, ^ compare each pair of bits; ~ inverts every bit. [S1]
  • Shift to multiply/divide by powers of two5 << 1 doubles to 10; 5 >>> 1 halves to 2. [S1]
  • Unsigned coercion for printing(dec >>> 0) forces an unsigned 32-bit view before .toString(2) to render binary. [S1]

📖 세부 내용 (Details)

Bitwise Operators — JavaScript provides seven bitwise operators: [S1]

Operator Name Description
& AND Sets each bit to 1 if both bits are 1
| OR Sets each bit to 1 if one of two bits is 1
^ XOR Sets each bit to 1 if only one of two bits is 1
~ NOT Inverts all the bits
<< Zero fill left shift Shifts left by pushing zeros in from the right and let the leftmost bits fall off
>> Signed right shift Shifts right by pushing copies of the leftmost bit in from the left, and let the rightmost bits fall off
>>> Zero fill right shift Shifts right by pushing zeros in from the left, and let the rightmost bits fall off

Note: JavaScript stores numbers as 64 bits floating point numbers, but all bitwise operations are performed on 32 bits binary numbers. [S1]

Bitwise AND — returns 1: [S1]

let x = 5 & 1;

Bitwise OR — returns 5: [S1]

let x = 5 | 1;

Bitwise XOR — returns 4: [S1]

let x = 5 ^ 1;

Bitwise NOT — returns -6: [S1]

let x = ~5;

Left Shift (<<) — returns 10: [S1]

let x = 5 << 1;

Signed Right Shift (>>) — returns -3: [S1]

let x = -5 >> 1;

Zero Fill Right Shift (>>>) — returns 2: [S1]

let x = 5 >>> 1;

Operator results summary (verbatim values from the page) [S1]

Expression Result
5 & 1 1
5 | 1 5
5 ^ 1 4
~5 -6
5 << 1 10
-5 >> 1 -3
5 >>> 1 2

Bitwise assignment operators — the page documents shift assignment operators (<<=, >>=, >>>=) and bitwise assignment operators (&=, ^=, |=). [S1]

Converting Decimal to Binary [S1]

function dec2bin(dec){
  return (dec >>> 0).toString(2);
}

Converting Binary to Decimal [S1]

function bin2dec(bin){
  return parseInt(bin, 2).toString(10);
}

The page also includes binary-representation tables showing decimal values and their binary form, and two's-complement format for negative numbers. The exact full numeric contents of those tables were not captured verbatim in the fetched source rendering: Not found in source.

🛠️ 적용 사례 (Applied in summary)

The page's own snippets are the canonical applied examples — the seven single-operator demonstrations and the dec2bin / bin2dec conversion helpers. No external project/commit applications found in the source.

💻 코드 패턴 (Code patterns)

Single bitwise operations (language: JavaScript):

let a = 5 & 1;   // 1
let b = 5 | 1;   // 5
let c = 5 ^ 1;   // 4
let d = ~5;      // -6
let e = 5 << 1;  // 10
let f = -5 >> 1; // -3
let g = 5 >>> 1; // 2

Base conversion helpers:

function dec2bin(dec){
  return (dec >>> 0).toString(2);
}
function bin2dec(bin){
  return parseInt(bin, 2).toString(10);
}

⚖️ 모순 및 업데이트 (Contradictions & updates)

No contradictions found in the source.

검증 상태 및 신뢰도

  • 상태: draft
  • 검증 단계: conceptual (실제 적용 사례 발견 시 applied/validated로 승격 가능)
  • 출처 신뢰도: B (W3Schools — widely used educational reference, not a primary standards body)
  • 신뢰 점수: 0.87
  • 중복 검사 결과: 신규 생성 (New discovery)

🔗 지식 그래프 (Knowledge Graph)

📚 출처 (Sources)

📝 변경 이력 (Change history)

  • 2026-06-23: Initial draft synthesized from the W3Schools "JavaScript Bitwise" page (Astra wiki-curation, P-Reinforce v3.1 format).