decimalcalc
Logic & Radix Engine•8, 16, 32 & 64-Bit Integers

Bitwise & Two's Complement Calculator

Calcolatore interattivo di logica bit a bit e complemento a due. Calcola AND, OR, XOR, NOT e scorrimenti di bit (<<, >>, >>>) per interi con e senza segno a 8, 16, 32 e 64 bit con visualizzatore.

Word Size:
Presets:
Interactive Bit Visualizer• Click bits to toggle live
Sign (MSB)1 Bit ON0 Bit OFF
Operand A:
& (AND)
Operand B:
Result (=):
Signed (Two's Complement)
0
Unsigned Decimal
0
Hexadecimal (0x)
0x00
Octal (0o)
0o0
2's

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):

fx

Step-by-Step Calculation Breakdown

Type any decimal value above to generate step-by-step arithmetic proof.

Bitwise Operations & Logic Reference Guide

Master truth tables, bitmasking techniques, and hardware register manipulation.

Standard Bitwise Operator Truth Tables

Binary Bit Logic
OperationSymbol / SyntaxLogic RuleExample
AND (&)A & B1 only if both bits are 11100 & 1010 = 1000 (8)
OR (|)A | B1 if at least one bit is 11100 | 1010 = 1110 (14)
XOR (^)A ^ B1 if bits are different (parity)1100 ^ 1010 = 0110 (6)
NOT (~)~AInvert 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 << nShift bits left, fills 0 on right (multiplies by 2ⁿ)00000101 << 2 = 00010100 (20)
Arithmetic Right Shift (>>)A >> nShift right, preserves sign bit MSB (divides by 2ⁿ)11110110 >> 1 = 11111011 (-5)
Logical Right Shift (>>>)A >>> nShift 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.

Strumenti di Conversione Correlati

Multi-Radix Suite
⚡ Binary Radix Tools

Convert raw binary bitstreams into Decimal, Hexadecimal nibbles, and Octal UNIX permissions with step-by-step proofs.

🎯Quiz

Esercizi e Quiz di Matematica

Interactive math & CS problems with unpaywalled step-by-step proofs

Open Tool→
📓Notebook

Quaderno degli Esercizi

Save problem sets & export clean PDF homework sheets

Open Tool→
📚Reference

Tavole di Riferimento STEM

Sig Figs, IEEE-754 float anatomy & powers of 2

Open Tool→
+−×÷Arithmetic

Calcolatore Decimale

Add, subtract, multiply & divide with column arithmetic proofs

Open Tool→
➗Math

Calcolatore di Frazioni

Add, subtract, multiply, divide & simplify fractions

Open Tool→
½→0.1Math

Frazione in Decimale

Convert fractions & mixed numbers to exact decimals & repeating cycles

Open Tool→
½Math

Decimale in Frazione

Mixed & improper fractions with GCD steps

Open Tool→
0x→10Hex

Esadecimale in Decimale

Convert Base-16 (0x) to Base-10 decimals with power expansion

Open Tool→
0xHex

Decimale in Esadecimale

Base-16 hex with byte spacing & RGB preview

Open Tool→
N→MRadix

Convertitore di Base N Arbitraria

Convert numbers between any radix base 2 through 36 with polynomial steps

Open Tool→
FLTFloat

Convertitore Virgola Mobile IEEE-754

Interactive 32-bit & 64-bit IEEE-754 floating point visualizer

Open Tool→
10Radix

Binario in Decimale

Convert base-2 bits to base-10 decimal & fractions

Open Tool→
B→H0x

Binario in Esadecimale

Convert 4-bit nibbles to Base-16 hexadecimal (0x)

Open Tool→
B→8Oct

Binario in Ottale

Convert 3-bit triplets to Base-8 octal & UNIX permissions

Open Tool→
0oOct

Decimale in Ottale

Convert decimals to Base-8 octal & chmod permissions

Open Tool→
8→10Radix

Ottale in Decimale

Convert Base-8 octal to decimal with powers of 8

Open Tool→
01→TDecode

Binario in Testo ASCII

Convert binary bits (0s and 1s) to readable ASCII text & characters

Open Tool→
T→01Bits

ASCII in Binario

Convert ASCII text and Unicode characters to 8-bit binary bits

Open Tool→
T→10ASCII

ASCII in Decimale

Convert ASCII text and Unicode characters to decimal byte sequences

Open Tool→
10→TASCII

Decimale in ASCII

Convert decimal codes & byte arrays to ASCII text

Open Tool→
01Bits

Decimale in Binario

Base-2 bits & IEEE-754 32-bit float inspection

Open Tool→
%Rate

Decimale in Percentuale

Percentage, basis points (bps) & gauge

Open Tool→
″Scale

Decimale in Pollici

1/16″ to 1/64″ fractional inches & metric ruler

Open Tool→
⏱Payroll

Calcolatore Ore Decimali e Busta Paga

Timecard punch hours, breaks, gross wages & FLSA rounding

Open Tool→
⏱Time

Decimale in Minuti

HH:MM:SS timecodes & payroll work logs

Open Tool→