Irreva logo
Explore Irreva
DeveloperFebruary 21, 2026· 6 min read· Updated June 10, 2026

What Is Binary and Hexadecimal Number Conversion

Hasanur Rahman

Written by Hasanur Rahman

Founder & Full-Stack Developer · Irreva · Rangpur, Bangladesh

Computers only understand two states: on and off, represented as 1 and 0. Binary is the natural language of hardware. Hexadecimal is a compact shorthand that humans and developers use when working with binary data. Understanding these numbering systems demystifies a lot of what happens inside computers, from color codes to memory addresses.

Binary — base 2 explained

Decimal is base 10: each digit position represents a power of 10. The number 347 means 3×100 + 4×10 + 7×1. Binary is base 2: each digit position represents a power of 2. The binary number 1011 means 1×8 + 0×4 + 1×2 + 1×1 = 11 in decimal.

A single binary digit (0 or 1) is a bit. Eight bits make a byte. A byte can represent 256 different values (0 through 255 in decimal, 00000000 through 11111111 in binary). This is why many limits in computing are multiples of 256 — file permissions, color channel values, ASCII character codes.

Converting decimal to binary means repeatedly dividing by 2 and recording remainders. Converting binary to decimal means multiplying each bit by its positional power of 2 and summing the results. An online converter handles this instantly.

Hexadecimal — base 16 and why developers use it

Hexadecimal uses 16 symbols: 0–9 and then A–F for values 10–15. One hex digit represents exactly 4 bits (a nibble). Two hex digits represent exactly 8 bits (one byte). This is why hexadecimal is so useful — it's a compact, human-readable representation of binary data.

A byte with value 255 in decimal is 11111111 in binary — eight digits. In hex, it's FF — two digits. For memory addresses, color codes, cryptographic hashes, and network identifiers, hexadecimal is the standard notation.

CSS colors are the most common hex in everyday web development: #FF5733 is R=255, G=87, B=51. Each pair of hex digits is one byte, representing one color channel's intensity from 0 to 255.

  • 0 in decimal = 0 in binary = 0 in hex
  • 10 in decimal = 1010 in binary = A in hex
  • 16 in decimal = 10000 in binary = 10 in hex
  • 255 in decimal = 11111111 in binary = FF in hex
  • 256 in decimal = 100000000 in binary = 100 in hex

Practical uses in web and software development

Hex color codes in CSS are the most visible everyday use. Understanding hex lets you mentally decode colors — #000000 is black (all zeros), #FFFFFF is white (all max), #FF0000 is pure red (red channel max, green and blue zero).

Unix file permissions (755, 644) are typically written in octal (base 8), not hex, but understanding the binary representation helps: 7 = 111 in binary means read+write+execute, 5 = 101 means read+execute.

Network programming frequently uses hex for IP addresses, MAC addresses, and packet inspection. Cryptographic outputs like SHA256 hashes and JWT signatures are always displayed in hexadecimal.

Frequently Asked Questions

How do I convert binary to decimal by hand?

Write out the binary number, then multiply each bit by 2 raised to the power of its position (counting from 0 on the right). Add the results. For 1101: (1×8) + (1×4) + (0×2) + (1×1) = 13.

Why does hex use A–F instead of numbers for 10–15?

Because using single characters for each digit value makes hex numbers easier to read and parse. If we used 10–15, the hex number '12' would be ambiguous — is it the decimal 12 or 1 followed by 2 in hex? Single characters eliminate this ambiguity.

What is the 0x prefix in programming?

The 0x prefix is a convention used in many programming languages (C, C++, JavaScript, Python, etc.) to indicate that a number is written in hexadecimal. So 0xFF means the hexadecimal value FF, which is 255 in decimal.

What is the difference between a bit and a byte?

A bit is the smallest unit of data — a single binary digit, either 0 or 1. A byte is 8 bits. Modern filesizes and memory are measured in bytes (KB, MB, GB). Network speeds are often measured in bits per second (Mbps), which is why they appear larger than file sizes.

Is octal still used?

Octal (base 8) is mostly used in Unix file permission notation. Each octal digit represents exactly 3 bits: read, write, execute. Beyond that, octal is rarely encountered in modern programming. Hexadecimal has largely replaced it for most purposes.

Hasanur Rahman

About the author

Hasanur Rahman

Founder & Full-Stack Developer · Irreva · Rangpur, Bangladesh

Hasanur Rahman is the founder of Irreva and a full-stack developer based in Rangpur, Bangladesh. He builds all of Irreva's tools with a focus on privacy-first, browser-based processing.