Bitwise & Two's Complement Calculator
대화형 비트 연산자 및 2의 보수 계산기. 8, 16, 32, 64비트 부호 있는/없는 정수에 대해 AND, OR, XOR, NOT 및 비트 시프트(<<, >>, >>>)를 실시간 비트 단위로 계산하고 시각화합니다.
Two's Complement Mathematical Weight Formula
In an N-bit two's complement integer, the MSB (Bit 7) carries a negative weight of -2N-1, and all other bits carry positive powers of 2 (+2i):
Step-by-Step Calculation Breakdown
Bitwise Operations & Logic Reference Guide
Master truth tables, bitmasking techniques, and hardware register manipulation.
Standard Bitwise Operator Truth Tables
Binary Bit Logic| Operation | Symbol / Syntax | Logic Rule | Example |
|---|---|---|---|
| AND (&) | A & B | 1 only if both bits are 1 | 1100 & 1010 = 1000 (8) |
| OR (|) | A | B | 1 if at least one bit is 1 | 1100 | 1010 = 1110 (14) |
| XOR (^) | A ^ B | 1 if bits are different (parity) | 1100 ^ 1010 = 0110 (6) |
| NOT (~) | ~A | Invert all bits (One's complement) | ~00101010 = 11010101 (-43 signed) |
| NAND | ~(A & B) | Inverted AND: 0 only if both are 1 | ~(1100 & 1010) = 0111 (7) |
| NOR | ~(A | B) | Inverted OR: 1 only if both are 0 | ~(1100 | 1010) = 0001 (1) |
| Left Shift (<<) | A << n | Shift bits left, fills 0 on right (multiplies by 2ⁿ) | 00000101 << 2 = 00010100 (20) |
| Arithmetic Right Shift (>>) | A >> n | Shift right, preserves sign bit MSB (divides by 2ⁿ) | 11110110 >> 1 = 11111011 (-5) |
| Logical Right Shift (>>>) | A >>> n | Shift right, fills 0 into MSB (zero-fill) | 11110110 >>> 1 = 01111011 (123) |
Bitmasking & Permissions
Operating systems and graphics engines store multiple boolean flags within a single byte using masks (e.g. flags & READ_ONLY).
XOR Parity & Cryptography
XOR has the property (A ^ B) ^ B = A, making it the bedrock of stream ciphers, RAID-5 disk parity recovery, and in-place variable swaps.
Color Packing (RGBA 32-bit)
Graphics cards pack Red, Green, Blue, and Alpha into one 32-bit integer: (R << 24) | (G << 16) | (B << 8) | A.
Frequently Asked Questions
Everything you need to know about decimal conversions, accuracy, and formulas.
01What is Two's Complement in binary computing?▼
Two's complement is the universal mathematical method computers use to represent signed integers (positive and negative numbers). In an N-bit system, the most significant bit (MSB) has a negative positional weight of -2ⁿ⁻¹, while all remaining bits have positive weights (+2ⁱ). To negate a number in two's complement, invert all bits (one's complement) and add 1.
02What is the difference between Arithmetic Shift (>>) and Logical Shift (>>>)?▼
Arithmetic right shift (>>) preserves the sign bit (MSB), meaning if the number is negative, 1s are shifted in from the left to preserve negativity. Logical right shift (>>>) always shifts in zeros from the left regardless of the sign, treating the bit pattern strictly as an unsigned integer.
03Why does ~0 equal -1 in two's complement?▼
Zero in 8-bit binary is 00000000. Inverting every bit gives 11111111. In two's complement, the MSB has weight -128, and the remaining 7 bits sum to +127. Calculating -128 + 127 = -1. Therefore, ~0 always equals -1 in any word size.
04How do bitwise masks work in software engineering?▼
A bitmask uses bitwise AND (&) to query specific flags, OR (|) to set flags, and XOR (^) to toggle flags. For example, testing if an integer is odd is performed with (n & 1) === 1, and clearing the lower 4 bits is achieved with n & 0xF0.
관련 변환 도구
Convert raw binary bitstreams into Decimal, Hexadecimal nibbles, and Octal UNIX permissions with step-by-step proofs.
수학 및 컴퓨터 과학 퀴즈
Interactive math & CS problems with unpaywalled step-by-step proofs
학생 문제 연습장
Save problem sets & export clean PDF homework sheets
이공계 요약 치트시트
Sig Figs, IEEE-754 float anatomy & powers of 2
소수 계산기
Add, subtract, multiply & divide with column arithmetic proofs
분수 계산기
Add, subtract, multiply, divide & simplify fractions
분수를 소수로 변환
Convert fractions & mixed numbers to exact decimals & repeating cycles
소수를 분수로 변환
Mixed & improper fractions with GCD steps
16진수를 10진수로 변환
Convert Base-16 (0x) to Base-10 decimals with power expansion
10진수를 16진수로 변환
Base-16 hex with byte spacing & RGB preview
N진법 임의 진수 변환기
Convert numbers between any radix base 2 through 36 with polynomial steps
IEEE-754 부동소수점 변환기
Interactive 32-bit & 64-bit IEEE-754 floating point visualizer
이진수를 10진수로 변환
Convert base-2 bits to base-10 decimal & fractions
이진수를 16진수로 변환
Convert 4-bit nibbles to Base-16 hexadecimal (0x)
이진수를 8진수로 변환
Convert 3-bit triplets to Base-8 octal & UNIX permissions
10진수를 8진수로 변환
Convert decimals to Base-8 octal & chmod permissions
8진수를 10진수로 변환
Convert Base-8 octal to decimal with powers of 8
2진수에서 ASCII 텍스트로 변환
Convert binary bits (0s and 1s) to readable ASCII text & characters
ASCII에서 2진수로 변환
Convert ASCII text and Unicode characters to 8-bit binary bits
ASCII에서 10진수로 변환
Convert ASCII text and Unicode characters to decimal byte sequences
10진수에서 ASCII로 변환
Convert decimal codes & byte arrays to ASCII text
10진수를 이진수로 변환
Base-2 bits & IEEE-754 32-bit float inspection
소수를 백분율(%)로 변환
Percentage, basis points (bps) & gauge
소수 인치를 분수 인치로 변환
1/16″ to 1/64″ fractional inches & metric ruler
소수점 근무시간 및 급여 계산기
Timecard punch hours, breaks, gross wages & FLSA rounding
소수 시간을 분/초로 변환
HH:MM:SS timecodes & payroll work logs