Bitwise & Two's Complement Calculator
対話型のビット単位論理演算および2の補数計算機。AND, OR, XOR, NOT, ビットシフト(<<, >>, >>>)を8/16/32/64ビット符号付き・符号なし整数で瞬時に計算・可視化します。
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
2進数から10進数へ変換
Convert base-2 bits to base-10 decimal & fractions
2進数から16進数へ変換
Convert 4-bit nibbles to Base-16 hexadecimal (0x)
2進数から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進数から2進数へ変換
Base-2 bits & IEEE-754 32-bit float inspection
小数からパーセントへ変換
Percentage, basis points (bps) & gauge
小数からインチ(分数)へ変換
1/16″ to 1/64″ fractional inches & metric ruler
10進数時間・タイムカード給与計算機
Timecard punch hours, breaks, gross wages & FLSA rounding
小数から分・時間へ変換
HH:MM:SS timecodes & payroll work logs