Developer

Binary, Octal, Decimal and Hex: How Number Bases Work

ToolOrbit Engineering 2 min readUpdated
Binary, Octal, Decimal and Hex: How Number Bases Work

Numbers can be written in many bases, and developers constantly switch between them: hexadecimal for colors and memory addresses, binary for flags and bitmasks, octal for file permissions, and decimal for everyday math. The ToolOrbit Number Base Converter moves a value between binary, octal, decimal, and hexadecimal instantly, and it is BigInt-safe so huge numbers stay exact.

How positional bases work

Every base assigns place values as powers of that base. In base 10 the digit positions are ones, tens, hundreds. In base 2 they are ones, twos, fours, eights. Hexadecimal uses sixteen symbols, 0-9 then A-F, so a single hex digit packs four binary bits, which is why hex is such a convenient shorthand for binary data.

decimal 255
binary  11111111
octal   377
hex     FF

Why BigInt safety matters

  • JavaScript numbers lose precision above 2^53, silently corrupting large values
  • BigInt arithmetic keeps every digit exact, no matter how long the number is
  • This is essential for 64-bit IDs, cryptographic values, and large bit fields
  • The converter handles arbitrarily long inputs without rounding errors
Tip: When debugging bit flags, convert your decimal value to binary to see exactly which bits are set, then flip the ones you need and convert back.

Using the converter

Type a value into any base field and the others update at once. You do not need to add prefixes like 0x or 0b; just enter the digits for that base. All computation happens locally in your browser, so even large or sensitive values never leave your machine.

Common uses

Reach for the converter when decoding a hex color, reading a permission mode such as 755 in octal, inspecting a bitmask, or sanity-checking a memory address. Keeping a quick base converter at hand removes a whole category of off-by-one and place-value mistakes.

Hex and binary you meet daily

The nibble you keep bumping into
DecimalHexBinary
100xA1010
150xF1111
2550xFF11111111
40950xFFF111111111111

IPv6 addresses, MAC addresses, color values (#FF8800 is just hex), URL percent codes and git object names are all hex in disguise. Binary shows up in flags and bitmasks. Learn “0xF = 1111” and the pattern extends everywhere: 0xFF = 1111 1111, 0xFFF = three nibbles. That is the whole trick — you read hex one nibble at a time.

One more everyday use: CSS colors, MAC addresses and IPv6 literals are all hex, and git short hashes are hex in miniature. Converting a color like #6c7bff to decimal RGB (116, 123, 255) is the same three two-digit hex pairs you now recognize — the converter just does the pairing for you.


Tools mentioned

More reading

View all guides
What Is Base64? How Encoding Works and Common Mistakes
Developer

What Is Base64? How Encoding Works and Common Mistakes

What Base64 encoding actually does, where it is used, and the mistakes that cause broken or oversized output.

2 min readUpdated
encodeURI vs encodeURIComponent: Which One to Use
Developer

encodeURI vs encodeURIComponent: Which One to Use

How percent-encoding works, the difference between encoding a whole URL and a single component, and the mistakes that break links.

2 min readUpdated
What Is a UUID? Version 4 vs Version 7 Explained
Developer

What Is a UUID? Version 4 vs Version 7 Explained

What a UUID looks like, why version 4 is the safe default, when version 7 is better, and best practices for IDs.

2 min readUpdated
How SHA-256 and SHA-512 Hashes Work: Hashing vs Encryption
Developer

How SHA-256 and SHA-512 Hashes Work: Hashing vs Encryption

What a hash function does, how to choose between SHA-256 and SHA-512, and why hashing is not encryption.

2 min readUpdated
What Is a JWT? Header, Payload and Signature Explained
Developer

What Is a JWT? Header, Payload and Signature Explained

A JSON Web Token has three parts. Learn what the header, payload and signature contain, how to read the claims, and why decoding is not verifying.

2 min readUpdated
What Is HTML Encoding? Entities & Escaping Explained
Developer

What Is HTML Encoding? Entities & Escaping Explained

Learn how HTML encoding works, why escaping prevents XSS and layout breaks, and how to encode and decode named, decimal, and hex entities.

2 min readUpdated
Unix Time Explained: Seconds, Milliseconds and Time Zones
Developer

Unix Time Explained: Seconds, Milliseconds and Time Zones

What a Unix timestamp is, how to tell seconds from milliseconds, how time zones come into it, and the values worth recognising.

2 min readUpdated
Regex Basics: How Patterns, Flags and Character Classes Work
Developer

Regex Basics: How Patterns, Flags and Character Classes Work

How a regular expression is built, what the flags change, and the character classes you will use most.

2 min readUpdated