HeoLab
ToolsBlogAboutContact
HeoLab

Free developer tools with AI enhancement. Built for developers who ship.

Tools

  • JSON Formatter
  • JWT Decoder
  • Base64 Encoder
  • Timestamp Converter
  • Regex Tester
  • All Tools →

Resources

  • Blog
  • What is JSON?
  • JWT Deep Dive
  • Base64 Explained

Company

  • About
  • Contact
  • Privacy Policy
  • Terms of Service

© 2026 HeoLab. All rights reserved.

Tools work in your browser. Zero data retention.

HomeBlogNumber Systems for Developers: Binary, Octal, and Hexadecimal Explained
Table of Contents▾
  • Why Different Number Systems?
  • Binary (Base 2)
  • Converting Decimal to Binary
  • Binary in JavaScript
  • Hexadecimal (Base 16)
  • Where Developers See Hex
  • Octal (Base 8)
  • Unix permissions
  • 7 = 111 (rwx) — owner has read, write, execute
  • 5 = 101 (r-x) — group has read and execute
  • 5 = 101 (r-x) — world has read and execute
  • 6 = 110 (rw-) — owner has read, write
  • 4 = 100 (r--) — group has read only
  • 4 = 100 (r--) — world has read only
  • Quick Conversion Reference
  • Convert Between Bases Instantly
guides#binary#hexadecimal#number-systems

Number Systems for Developers: Binary, Octal, and Hexadecimal Explained

A practical guide to number systems — how binary, octal, and hexadecimal work, why developers need them, and how to convert between bases quickly.

Trong Ngo
February 28, 2026
4 min read

Most people learn decimal (base 10) and stop there. But as a developer, you'll regularly encounter binary, octal, and hexadecimal — in file permissions, color codes, memory addresses, bit flags, and character encodings. This guide makes these systems intuitive.

Why Different Number Systems?

Computers only understand binary (0s and 1s). All other number systems are just convenient ways for humans to read binary data:

  • Binary (base 2): Direct computer language — 0 and 1
  • Octal (base 8): 3 binary digits per octal digit — common in Unix permissions
  • Hexadecimal (base 16): 4 binary digits per hex digit — compact binary representation
  • Decimal (base 10): Human-friendly counting system

Binary (Base 2)

Binary uses only 0 and 1. Each position is a power of 2:

Position:  8    4    2    1
Binary:    1    0    1    1  = 8 + 0 + 2 + 1 = 11 (decimal)

Converting Decimal to Binary

Divide repeatedly by 2, record remainders from bottom to top:

42 ÷ 2 = 21 remainder 0
21 ÷ 2 = 10 remainder 1
10 ÷ 2 =  5 remainder 0
 5 ÷ 2 =  2 remainder 1
 2 ÷ 2 =  1 remainder 0
 1 ÷ 2 =  0 remainder 1

Read remainders bottom to top: 101010
42 in decimal = 101010 in binary

Binary in JavaScript

// Decimal to binary
(42).toString(2);    // '101010'

// Binary to decimal
parseInt('101010', 2); // 42

// Binary literals
const flags = 0b1010;  // 10 in decimal

// Bitwise operations
const READ  = 0b001; // 1
const WRITE = 0b010; // 2
const EXEC  = 0b100; // 4

const userPerms = READ | WRITE;   // 0b011 = 3
const canRead   = userPerms & READ; // truthy if READ bit is set

Hexadecimal (Base 16)

Hex uses 16 symbols: 0-9 and A-F (where A=10, B=11, C=12, D=13, E=14, F=15):

Hex:  0  1  2  3  4  5  6  7  8  9  A   B   C   D   E   F
Dec:  0  1  2  3  4  5  6  7  8  9  10  11  12  13  14  15

One hex digit = exactly 4 binary digits (nibble):

Hex F = binary 1111
Hex A = binary 1010
Hex FF = binary 11111111 = decimal 255

Where Developers See Hex

Colors: #2563eb = #25 (red=37) 63 (green=99) eb (blue=235)

Memory addresses: 0x7fff5fbff8b0

SHA-256 hashes: a665a45920422f9d417e4867efdc4fb8a04a1f3fff1fa07e998e86f7f7a27ae3

UUID: 550e8400-e29b-41d4-a716-446655440000

// Decimal to hex
(255).toString(16);    // 'ff'
(255).toString(16).toUpperCase(); // 'FF'

// Hex to decimal
parseInt('ff', 16);    // 255
parseInt('2563eb', 16); // 2450411

// Hex literal
const color = 0x2563eb; // 2450411

// Parse hex color to RGB
function hexToRgb(hex) {
  const n = parseInt(hex.replace('#', ''), 16);
  return { r: (n >> 16) & 0xff, g: (n >> 8) & 0xff, b: n & 0xff };
}
hexToRgb('#2563eb'); // { r: 37, g: 99, b: 235 }

Octal (Base 8)

Octal uses digits 0–7. Each octal digit represents exactly 3 binary bits — which maps perfectly to Unix file permission triplets (owner/group/world):

# Unix permissions
chmod 755 script.sh
# 7 = 111 (rwx) — owner has read, write, execute
# 5 = 101 (r-x) — group has read and execute
# 5 = 101 (r-x) — world has read and execute

chmod 644 config.json
# 6 = 110 (rw-) — owner has read, write
# 4 = 100 (r--) — group has read only
# 4 = 100 (r--) — world has read only
// Decimal to octal
(8).toString(8);   // '10'
(255).toString(8); // '377'

// Octal to decimal
parseInt('755', 8); // 493

// Octal literals (prefix 0o)
const perms = 0o755; // 493

Quick Conversion Reference

DecimalBinaryOctalHex
0000000
81000108
10101012A
15111117F
16100002010
25511111111377FF
256100000000400100

Convert Between Bases Instantly

Use HeoLab's Base Converter to convert numbers between any bases — binary, octal, decimal, hex, and beyond — with step-by-step explanations.

Try These Tools

Number Base Converter

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

Related Articles

QR Codes for Developers: How They Work and How to Generate Them

4 min read

Unix Timestamps: A Complete Developer's Guide

2 min read

Base64 is Not Encryption: Security Misconceptions Explained

1 min read

Back to Blog

Table of Contents

  • Why Different Number Systems?
  • Binary (Base 2)
  • Converting Decimal to Binary
  • Binary in JavaScript
  • Hexadecimal (Base 16)
  • Where Developers See Hex
  • Octal (Base 8)
  • Unix permissions
  • 7 = 111 (rwx) — owner has read, write, execute
  • 5 = 101 (r-x) — group has read and execute
  • 5 = 101 (r-x) — world has read and execute
  • 6 = 110 (rw-) — owner has read, write
  • 4 = 100 (r--) — group has read only
  • 4 = 100 (r--) — world has read only
  • Quick Conversion Reference
  • Convert Between Bases Instantly

Related Articles

QR Codes for Developers: How They Work and How to Generate Them

4 min read

Unix Timestamps: A Complete Developer's Guide

2 min read

Base64 is Not Encryption: Security Misconceptions Explained

1 min read