DigitHelm

Number Base Converter | Binary, Hex

Convert numbers between binary, octal, decimal, and hexadecimal bases.

INPUT BASE

CONVERT TO

or custom:

What Is the Number Base Converter | Binary, Hex?

This number base converter converts any integer between bases 2 and 36. Enter a number in any base and instantly see the equivalent in binary, octal, decimal, hexadecimal, and any custom base simultaneously. A step-by-step division algorithm shows exactly how the conversion is performed, ideal for learning.

  • All four common bases at once: every conversion shows binary, octal, decimal, and hex results in a single view.
  • Custom base 2–36: convert to any base using digits 0–9 and A–Z.
  • Step-by-step division algorithm: the remainder table shows exactly how decimal is converted to the target base.
  • Large number support: uses JavaScript BigInt for accurate conversion of numbers with many digits.
  • Bit length display: shows how many bits are needed to represent the value.

Formula

Value = Σ dᵢ × bⁱ
Positional notation: digit × base raised to its position index (right-to-left from 0)
BaseNameDigitsCommon Use
2Binary0, 1CPU logic, memory addressing, network masks
8Octal0–7Unix file permissions (chmod 755)
10Decimal0–9Human arithmetic, everyday numbers
16Hex0–9, A–FMemory addresses, color codes (#FF5733), byte values
32Base-320–9, A–VEncoding (Base32 in TOTP/MFA tokens)
36Base-360–9, A–ZURL shorteners, unique identifiers

How to Use

  1. 1Select the input base using the preset buttons (Binary, Octal, Decimal, Hex) or enter a custom base.
  2. 2Type your number in the input field. For bases > 10, use letters A–Z (automatically uppercased).
  3. 3Select the target base using the "Convert to" buttons or enter a custom base.
  4. 4Click Convert or press Enter to see results in all four standard bases plus your custom target.
  5. 5Use the Copy buttons to copy any individual result.
  6. 6The division steps table below shows the algorithm used for the conversion.
  7. 7Click Clear to reset all inputs.

Example Calculation

Example, 255 (decimal) to all bases

Input: 255 (base 10) Binary (base 2): 1111 1111 → 8 bits, all set Octal (base 8): 377 → two 7s Hex (base 16): FF → common for 255 in color codes Step-by-step decimal → binary: 255 ÷ 2 = 127, remainder 1 127 ÷ 2 = 63, remainder 1 63 ÷ 2 = 31, remainder 1 31 ÷ 2 = 15, remainder 1 15 ÷ 2 = 7, remainder 1 7 ÷ 2 = 3, remainder 1 3 ÷ 2 = 1, remainder 1 1 ÷ 2 = 0, remainder 1 Read remainders bottom-up: 11111111 = FF = 255

Example, Converting from Binary

Input: 10101100 (base 2) = 1×2⁷ + 0×2⁶ + 1×2⁵ + 0×2⁴ + 1×2³ + 1×2² + 0×2¹ + 0×2⁰ = 128 + 0 + 32 + 0 + 8 + 4 + 0 + 0 = 172 (decimal) = AC (hex) = 254 (octal)

Hexadecimal in programming

Hex (base 16) is the standard way to represent byte values in code. A byte (8 bits) takes exactly 2 hex digits (00–FF). Colors in CSS use 6 hex digits: #RRGGBB. Memory addresses in debuggers are shown in hex. Bitwise operations are easiest to reason about in hex or binary.

Understanding Number Base Converter | Binary, Hex

How Positional Numeral Systems Work

Every positional numeral system represents a number as a sum of digits multiplied by powers of the base. In decimal (base 10), 345 means 3×10² + 4×10¹ + 5×10⁰ = 300 + 40 + 5. The same principle applies in any base: binary 1011 means 1×2³ + 0×2² + 1×2¹ + 1×2⁰ = 8 + 0 + 2 + 1 = 11 (decimal).

The digits in each base are the integers from 0 to base−1. For bases beyond 10, letters supplement the digits: base 16 uses A=10, B=11, C=12, D=13, E=14, F=15. Base 36 extends to Z=35. Any representation up to base 36 can be handled with the 36 characters 0–9 and A–Z.

Binary and Hexadecimal in Computing

Binary is the native language of digital computers because transistors have two states, on (1) and off (0). All data in a computer is ultimately binary: text, images, audio, machine code. However, binary numbers become unwieldy for humans (255 decimal = 11111111 binary). Hexadecimal was adopted as a human-friendly shorthand: each hex digit represents exactly 4 binary bits (a nibble), so 2 hex digits perfectly represent one byte.

  • Memory address 0x1A3F: each byte is two hex digits; 0x prefix indicates hex in code.
  • Color #FF5733: FF=255 red, 57=87 green, 33=51 blue, each channel 0–255.
  • IPv4 subnet mask: 255.255.255.0 = FF.FF.FF.00 in hex.
  • ASCII table: character A = decimal 65 = hex 41 = binary 01000001.

Octal and Unix File Permissions

Octal (base 8) groups binary into 3-bit chunks instead of 4. Each octal digit represents 3 bits, making it useful in contexts where data is naturally organized in 3-bit groups. The most prominent example is Unix/Linux file permissions: chmod 755 sets permissions to rwxr-xr-x. Each digit is an octal representation of a 3-bit permission group (owner, group, other): 7 = 111 = rwx, 5 = 101 = r-x.

  • chmod 644 → rw-r--r-- (6=110=rw-, 4=100=r--, 4=100=r--)
  • chmod 777 → rwxrwxrwx (7=111=rwx for all three)
  • chmod 400 → r-------- (owner read only)

The Division Algorithm for Base Conversion

To convert a decimal number to base b, repeatedly divide by b and record remainders. The remainders, read from last to first, give the representation in base b. For 255 → binary: 255÷2=127 rem 1, 127÷2=63 rem 1, …, 1÷2=0 rem 1. Remainders bottom-up: 11111111. This calculator shows every division step, an excellent way to understand the algorithm for exams and programming interviews.

Frequently Asked Questions

How do I convert a number from decimal to binary?

Use the repeated division by 2 method. Divide the decimal number by 2 repeatedly, recording the remainder each time. When the quotient reaches 0, read the remainders from bottom to top.

Convert 13 to binary: 13 ÷ 2 = 6, rem 1 6 ÷ 2 = 3, rem 0 3 ÷ 2 = 1, rem 1 1 ÷ 2 = 0, rem 1 Read bottom to top: 1101 Check: 1×2³ + 1×2² + 0×2¹ + 1×2⁰ = 8+4+0+1 = 13 ✓

This calculator performs these steps automatically and displays the complete division table, making it easy to follow and verify the conversion.

Why is hexadecimal used in programming?

Hexadecimal (base 16) is used because it is compact and maps directly to binary: one hex digit = exactly 4 binary bits (a nibble), two hex digits = one byte (8 bits). This makes it much easier to read binary values than counting 8 zeros and ones.

  • 255 decimal = FF hex = 11111111 binary, 2 hex digits vs 8 binary digits
  • Memory addresses: 0x00BFFF is far cleaner than its 18-digit binary equivalent
  • Color codes: #FF0000 = full red (255, 0, 0), intuitive in 6 hex digits
  • Bitwise AND/OR/XOR operations are easiest to reason about in hex

What bases are used in practice beyond binary, octal, decimal, and hex?

Several other bases have practical applications:

  • Base 32: used in TOTP authentication tokens, IPFS content identifiers, Crockford encoding.
  • Base 36 (0–9, A–Z): URL shorteners, unique identifiers (case-insensitive, alphanumeric only).
  • Base 60 (sexagesimal): used by Babylonians, survives in time (60 seconds, 60 minutes) and angles (360°).
  • Base 12 (duodecimal): proposed as superior to decimal because 12 has more divisors (2,3,4,6) than 10 (2,5).
  • Base 3 (ternary): proposed for balanced ternary computing (−1, 0, +1 digits).

How do I convert from binary to hexadecimal without going through decimal?

Group the binary number into groups of 4 bits from right to left, then convert each group to its hex equivalent. No intermediate decimal step needed.

Binary: 10110111 1010 Group in 4s (right to left): 1011 0111 1010 Convert each: B 7 A Result: 0xB7A = 2938 decimal Hex-to-binary is the reverse: expand each hex digit to 4 bits. F → 1111, A → 1010, 5 → 0101

This grouping works because 16 = 2⁴, hex and binary are powers of the same base. Similarly, octal groups binary into 3-bit chunks because 8 = 2³.

What are the valid digits for each base?

Each base uses digits from 0 to base−1. For bases above 10, letters supplement:

Base 2: 0, 1 Base 8: 0–7 Base 10: 0–9 Base 12: 0–9, A, B Base 16: 0–9, A, B, C, D, E, F Base 20: 0–9, A–J Base 36: 0–9, A–Z

This calculator accepts uppercase or lowercase input and automatically uppercases it. Entering digits invalid for the selected base produces an error with a specific explanation.

How do Unix file permissions relate to octal?

Unix file permissions are a set of three 3-bit groups: owner, group, and others. Each 3-bit group can be represented as a single octal digit (0–7).

rwx r-x r-- 111 101 100 ← binary 7 5 4 ← octal → chmod 754 7 = 111 = rwx (read, write, execute) 6 = 110 = rw- (read, write) 5 = 101 = r-x (read, execute) 4 = 100 = r-- (read only) 0 = 000 = --- (no permission)

This is why chmod uses 3-digit octal numbers. It is a direct mapping from 9 permission bits to 3 octal digits, no decimal conversion needed.

Can this converter handle very large numbers?

Yes, this calculator uses JavaScript BigInt for conversions, which supports arbitrary-precision integers with no overflow up to 60 input digits. Standard JavaScript numbers (64-bit floating point) lose precision for integers above 2⁵³ ≈ 9 × 10¹⁵, which would corrupt binary representations of large values. BigInt avoids this entirely.

  • Safe for 64-bit integers (up to 9,223,372,036,854,775,807)
  • Safe for 128-bit values used in IPv6 addresses and UUIDs
  • Handles numbers up to 60 digits (input limit)
  • Results are always exact, no floating-point rounding

Related Calculators