Hexadecimal Calculator & Bitwise Tool
Perform base-16 arithmetic (+, -, *, /) and bitwise logic (AND, OR, XOR, NOT, left/right shifts) with simulated 8, 16, 32, and 64-bit hardware register overflow.
Hexadecimal Arithmetic & Bitwise Logic Principles
Calculations in hexadecimal mirror digital ALU (Arithmetic Logic Unit) hardware in central processing units:
- Addition (+): When column totals equal or exceed 16, a carry of 1 is propagated to the left. E.g.,
0x0F + 0x01 = 0x10. - Subtraction (-): Borrowing from the next column brings over a value of 16 (not 10). E.g.,
0x10 - 0x01 = 0x0F. - Bitwise AND (&): Yields 1 only where both bits are 1. Commonly used for bitmasking and extracting specific byte flags.
- Bitwise OR (|): Yields 1 if either bit is 1. Used to turn on specific configuration flags.
- Bitwise XOR (^): Yields 1 if bits differ. Used for toggling bits and lightweight cryptographic mixing.
To learn more about negative signed values, read our guide: Two's Complement Explained.
Verified Calculation Test Vectors
Addition: FF + 1
Rolls over the 8-bit byte into a 9th carry bit.
Addition: 3F + 64
Two multi-digit operands without overflow.
Subtraction: 10 - 1
Demonstrates borrowing 16 from the high column.
Multiplication: 1F * 3
31 * 3 = 93 in base 10.
Bitwise XOR: A5 XOR 5A
Alternating bit pattern produces all ones.
Bitwise AND: F0 AND 3C
Extracts overlapping bits.
Frequently Asked Questions
Direct answers to technical and practical questions regarding this tool and base-16 conversion.
How do you add hexadecimal numbers?
Hexadecimal addition follows the same column addition rules as decimal math, but carries occur at sixteen instead of ten. If the sum of a column is 16 or greater, subtract 16 to find the current digit and carry 1 to the next column to the left. For example, 0x0F + 0x01: 15 + 1 = 16 → digit 0, carry 1 → 0x10.
What is bitwise XOR in hexadecimal?
Bitwise XOR (exclusive OR) compares corresponding bits of two hexadecimal numbers. For each bit position, the result bit is 1 if exactly one of the input bits is 1, and 0 if both bits are the same. For example, 0xA5 (10100101) XOR 0x5A (01011010) results in 0xFF (11111111) because every pair of bits differs.
How does bit-width masking work in this calculator?
When a specific word size is selected (such as 8-bit or 32-bit), the calculator simulates computer hardware registers by truncating results that exceed the bit width (overflow). For instance, in an 8-bit register, 0xFF + 1 = 0x100 wraps around to 0x00 with an overflow flag.
How do bitwise shift operators (SHL and SHR) work on hex numbers?
A left shift (SHL / <<) moves bits to the left, which is mathematically equivalent to multiplying by powers of 2. Shifting left by 4 bits shifts the number by one entire hexadecimal digit (multiplying by 16). A right shift (SHR / >>) moves bits to the right, dividing by powers of 2.
Related Conversion Tools & Resources
Explore companion converters, bitwise arithmetic calculators, and reference charts.
Hex to Decimal Converter
Convert hexadecimal to decimal instantly with digit-by-digit positional steps. Supports 0x prefixes, signed two's complement, and BigInt precision.
Decimal to Hex Converter
Convert decimal integers to hexadecimal with repeated division tables. Handles negative numbers via two's complement and BigInt exact values.
Hex to Binary Converter
Convert hexadecimal digits into 4-bit binary nibbles. Features visual nibble breakdown, customizable grouping, and leading zero toggles.
Two's Complement Explained: Signed Math in Hex & Binary
Understand how signed integers are stored in computers using two's complement notation. Bit inversion, adding one, overflow, and hex representations.
Sources & Technical References
- [1]IEEE Standard for Binary and Hexadecimal Computer Arithmetic (IEEE 754) — IEEE Standards Association
Hardware specifications for ALU integer registers, carries, borrows, and overflow.
Technical Verification & Editorial Accountability
Written by Sarah Chen (Embedded Systems Engineer) • Verified by Marcus Brody, PE