Binary & Hexadecimal Calculator

Programmer's base conversion and bitwise arithmetic utility: Hexadecimal, Decimal, Octal, and Binary with interactive 32-bit register grid, bit shifts, and 2's complement.

🧮 Calculator 0x Hex / 0b Bin / Dec / Oct ⚙️ AND, OR, XOR, NOT, Shifts 🎛️ Interactive 32-Bit Grid
HEX
DEC
OCT
BIN
Interactive 32-Bit Register (Click bit to toggle 0 / 1):
Signed 32-bit Int: 255
Unsigned 32-bit Int: 255
ASCII Representation: 'u00ff'
Quick Overview & Direct Answer

Binary & Hexadecimal Programmer's Calculator: Convert and calculate across Binary, Hexadecimal, Octal, and Decimal with bitwise operations (AND, OR, XOR, NOT, bit shifts) and interactive 32-bit switch grid.

Primary Use Everyday arithmetic, specialized formulas, percentage & ratio math
Input Formats Numbers, mathematical operations, percentage values
Output Format Real-time computed answers and calculation history
Processing Mode 100% Client-Side In-Browser Processing
Access Tier Free, unlimited, no sign-up needed

Computer Architecture & Binary Radix Systems

In digital computing, all processors operate on transistors switching between electrical voltages representing binary states ($0$ and $1$). Because reading long sequences of binary bits is unwieldy for software engineers, radix systems with base powers of two are utilized:

  • Binary (Base-2): Uses symbols ${0, 1}$. Every position represents a power of $2$ ($2^0, 2^1, 2^2, dots$).
  • Octal (Base-8): Uses symbols ${0, 1, 2, 3, 4, 5, 6, 7}$. Every octal digit represents exactly $3$ binary bits ($2^3 = 8$). Standard in Unix file permissions (`chmod 755`).
  • Hexadecimal (Base-16): Uses digits ${0-9}$ and letters ${A, B, C, D, E, F}$. Every hex character represents exactly $4$ binary bits (a nibble, $2^4 = 16$), making two hex characters equal to exactly one 8-bit byte ($0x00$ to $0xFF$).

Bitwise Logic Operations

Bitwise operators manipulate integer representations at the individual bit level:

  • AND ($&$): Result bit is $1$ only if both corresponding bits are $1$. Used for bitmasking and flag extraction.
  • OR ($|$): Result bit is $1$ if either bit is $1$. Used for setting configuration flags.
  • XOR ($oplus$): Result bit is $1$ if bits are strictly different. Used in cryptography, parity calculations, and register zeroing (`XOR EAX, EAX`).
  • NOT ($sim$): Inverts every bit ($1 to 0$, $0 to 1$).
  • Logical Left Shift ($ll$): Shifts bits left by $k$ positions, equivalent to multiplying by $2^k$.
  • Logical Right Shift ($gg$): Shifts bits right by $k$ positions, equivalent to integer division by $2^k$.

Two's Complement Signed Integer Representation

Modern microprocessors represent negative integers using Two's Complement. In a 32-bit signed integer, the most significant bit (MSB, bit 31) acts as the sign bit ($0$ for positive, $1$ for negative). To negate a number in two's complement:

$$text{Two's Complement}(x) = (sim x) + 1$$

Frequently Asked Questions

Hexadecimal aligns perfectly with byte boundaries. One byte is always 2 hex digits, 32-bit memory addresses are exactly 8 hex digits, and 64-bit addresses are 16 hex digits. In decimal, powers of 10 do not align with binary hardware bytes.

A logical right shift (>>>) fills newly vacated high-order bits with zeros. An arithmetic right shift (>>) preserves the sign bit by sign-extending negative numbers with ones, preserving negative integer division.

Big-endian stores the most significant byte (MSB) at the lowest memory address, whereas little-endian (standard in x86 and ARM processors) stores the least significant byte (LSB) first.

Bitwise operators process individual bit pairs: AND yields 1 only if both bits are 1; OR yields 1 if either bit is 1; XOR yields 1 if the bits differ; NOT flips all bits.