Skip to content
← All Tools
🔒All processing in your browser 🚫No uploads stored 🛡️Privacy-first conversion tools No login required
Guide

Converting Numbers Between Bases: A Developer's Reference

Bill Crawford — Developer Guide — 2026  ·  Last updated December 11, 2025

Number base conversion is a fundamental skill for systems programming, networking, graphics, and cryptography. This reference covers all the conversions you'll encounter regularly.

Connect on LinkedIn →

Convert numbers instantly: Our Number Base Converter converts between decimal, hex, binary, and octal — with live updates as you type.

Open Number Base Converter →

Table of Contents

  1. Quick Reference Table
  2. Converting to Decimal
  3. Converting Decimal to Binary
  4. Hex ↔ Binary Shortcut
  5. In Code
  6. When You'll Use Each Base
  7. Common Conversion Mistakes
  8. Real-World Debugging Scenarios
  9. Base Conversion in Different Languages

Quick Reference Table

DecimalBinaryOctalHex
0000000
1000111
4010044
81000108
10101012A
15111117F
160001 00002010
2551111 1111377FF
2560001 0000 0000400100

Converting to Decimal

Multiply each digit by its positional power and sum:

Binary 1011 = (1×8) + (0×4) + (1×2) + (1×1) = 11
Hex 2F     = (2×16) + (15×1) = 47
Octal 755  = (7×64) + (5×8) + (5×1) = 509

Converting Decimal to Binary

Repeatedly divide by 2 and collect remainders bottom-to-top:

45 ÷ 2 = 22 remainder 1  ← LSB
22 ÷ 2 = 11 remainder 0
11 ÷ 2 =  5 remainder 1
 5 ÷ 2 =  2 remainder 1
 2 ÷ 2 =  1 remainder 0
 1 ÷ 2 =  0 remainder 1  ← MSB

Read remainders bottom-to-top: 101101 = 45

Hex ↔ Binary Shortcut

Each hex digit maps exactly to 4 bits — the fastest way to convert:

0=0000  1=0001  2=0010  3=0011
4=0100  5=0101  6=0110  7=0111
8=1000  9=1001  A=1010  B=1011
C=1100  D=1101  E=1110  F=1111

// 0xA5 → 1010 0101
// 0x3F → 0011 1111
// Binary 1101 0010 → 0xD2

In Code

// JavaScript
parseInt("1011", 2)   // binary → decimal: 11
parseInt("FF", 16)    // hex → decimal: 255
(255).toString(2)     // decimal → binary: "11111111"
(255).toString(16)    // decimal → hex: "ff"

# Python
int("1011", 2)        # 11
int("FF", 16)         # 255
bin(255)              # "0b11111111"
hex(255)              # "0xff"
oct(255)              # "0o377"

// Go
strconv.ParseInt("FF", 16, 64)
strconv.FormatInt(255, 2)

When You'll Use Each Base

Common Conversion Mistakes

The most frequent error when converting between number bases is confusing the direction of the conversion. When converting decimal to binary by repeated division, the remainders must be read from bottom to top — reading them in the order they're computed gives you the number reversed. A related mistake is forgetting that leading zeros matter in certain contexts: the byte 0x0A is 10 in decimal, and dropping the leading zero changes nothing mathematically, but tools that expect fixed-width representations (like hex editors or network analyzers) will misinterpret the value.

Another common pitfall is mixing up signed and unsigned representations. In two's complement, the binary value 11111111 is 255 as an unsigned byte but -1 as a signed byte. If you're debugging memory dumps or network packets, getting this wrong can send you chasing the wrong value entirely.

Octal is a frequent source of bugs in JavaScript specifically. A numeric literal starting with 0 (like 0755) is interpreted as octal in non-strict mode, which means 0100 is 64, not 100. This is why modern JavaScript uses the explicit 0o prefix for octal (0o755) and strict mode disallows the old syntax.

Real-World Debugging Scenarios

Number base conversion comes up constantly in practical work. When reading a hex dump from a network packet capture, each pair of hex digits represents a single byte. If you're analyzing a TCP header and see 01BB in the destination port field, converting from hex to decimal gives you 443 — the standard HTTPS port. Without being comfortable with hex-to-decimal conversion, network debugging is nearly impossible.

Color values in CSS and design tools use hex extensively. The color #FF6B35 breaks down to R=255, G=107, B=53. Understanding this mapping lets you tweak colors numerically rather than relying on a picker — adding 20 to the green channel shifts the hue toward yellow, and you can calculate that directly.

Unix file permissions are the classic octal use case. The permission 755 breaks down to three octal digits: owner (7 = rwx = 111 in binary), group (5 = r-x = 101), and others (5 = r-x = 101). Each digit maps to a 3-bit field controlling read, write, and execute access. Understanding this octal-to-binary relationship makes permission debugging instantaneous.

Memory addresses in debuggers and crash logs are always hexadecimal. A segmentation fault at address 0x7FFEE3B0C4A0 tells you the memory region (the high bytes indicate whether it's stack, heap, or mapped memory) — but only if you can read hex fluently.

Base Conversion in Different Languages

Most modern languages have built-in base conversion, but the APIs differ. In Python, int() accepts a base parameter for parsing, while bin(), hex(), and oct() format numbers with prefixes. JavaScript's parseInt() and Number.toString() handle arbitrary bases from 2 to 36. In C and C++, strtol() converts strings with a base parameter, while format specifiers like %x, %o, and %b (C23) handle output.

For languages that lack native base conversion — or when you need bases beyond 36 — the algorithm is always the same: repeatedly divide by the target base and collect remainders. This is worth knowing even if you never implement it yourself, because it demystifies what the built-in functions are doing under the hood.

Further reading: MDN — Bitwise Operators

BC
Bill Crawford
Founder, Data Conversion Center

Bill Crawford is a data systems developer and technical founder with over 30 years of professional experience in accounting, finance, and business operations.

He holds a Bachelor's degree in Accounting and has spent more than three decades working within financial and operational environments. Over the past 10 years, he has been heavily involved in the development, implementation, and refinement of financial and enterprise data systems for both Fortune 500 companies and smaller organizations.

His work bridges finance and technology — combining deep domain knowledge in structured reporting and accounting workflows with hands-on SQL development and database architecture experience.

Bill founded DataConversionCenter.com to build practical, browser-based tools that simplify complex data challenges, including:

Rather than focusing on theoretical examples, his tools and articles are informed by real-world challenges encountered in enterprise reporting systems, financial databases, and operational data environments.

Professional Background

Bill's mission is to reduce friction in data workflows — particularly for professionals working with structured financial, operational, and reporting data.