...
Contact Us Contact Us

Binary, Decimal and Hex: How to Convert by Hand and Where You Already Use Them

Binary, Decimal and Hex: How to Convert by Hand and Where You Already Use Them Binary, Decimal and Hex: How to Convert by Hand and Where You Already Use Them

Binary is the only number system a computer natively understands, and it is also one you already know: you count in tens because you have ten fingers, and binary is the same idea with two. Once that clicks, converting between binary, decimal and hexadecimal by hand takes a minute, and the things that seemed arbitrary (why file sizes come in 1,024s, why an IP address has four numbers up to 255, why colours are written as #FF8800) all fall out of the same rule. This guide covers the conversions in both directions, hexadecimal as the shorthand programmers actually use, and the places you’ll meet binary without a computer science degree.

Place value, in any base

Decimal 253 means 2 × 100 + 5 × 10 + 3 × 1: each place is a power of ten. Binary works the same way with powers of two. The places from the right are 1, 2, 4, 8, 16, 32, 64, 128, 256…

So binary 11111101 is 128 + 64 + 32 + 16 + 8 + 4 + 0 + 1 = 253. Each digit (bit) is either 0 or 1, so you either include that place’s value or you don’t.

Advertisement

Binary to decimal

Write the place values above the bits, add the ones where the bit is 1:

Place: 128  64  32  16   8   4   2   1
Bits:    1   0   1   1   0   0   1   0
Sum:   128 + 0 + 32 + 16 + 0 + 0 + 2 + 0 = 178

The Binary to Decimal Converter shows this breakdown for any input, and converts the other way, plus hexadecimal and octal.

Decimal to binary

Two methods; use whichever feels natural.

Subtract the largest power that fits. 178: largest power of 2 not above it is 128, leaving 50. Next, 32 fits (leaving 18), then 16 (leaving 2), then 2 (leaving 0). Places used: 128, 32, 16, 2 → 10110010.

Divide by 2 and read the remainders upward.

178 ÷ 2 = 89 r0
 89 ÷ 2 = 44 r1
 44 ÷ 2 = 22 r0
 22 ÷ 2 = 11 r0
 11 ÷ 2 =  5 r1
  5 ÷ 2 =  2 r1
  2 ÷ 2 =  1 r0
  1 ÷ 2 =  0 r1
Read bottom to top: 10110010

Hexadecimal: binary for humans

Long binary strings are unreadable, so programmers write them in base 16, where each hex digit stands for exactly four bits:

Hex Binary Decimal Hex Binary Decimal
0 0000 0 8 1000 8
1 0001 1 9 1001 9
2 0010 2 A 1010 10
3 0011 3 B 1011 11
4 0100 4 C 1100 12
5 0101 5 D 1101 13
6 0110 6 E 1110 14
7 0111 7 F 1111 15

Binary 1011 0010 → hex B2. Hex FF → binary 1111 1111 → decimal 255. Conversion between binary and hex is just a table lookup four bits at a time, which is why hex is used for everything from memory addresses to colour codes. Hex is written with a 0x prefix in code (0xB2) or a # in CSS.

Where you meet binary without noticing

  • Colours. #FF8800 is three hex bytes: red 255, green 136, blue 0. Fully bright red, half green, no blue: orange.
  • IP addresses. 192.168.1.1 is four bytes, each 0–255, which is 0 to 11111111 in binary. A subnet mask like /24 means the first 24 bits identify the network.
  • File sizes. A kilobyte was traditionally 1,024 bytes (2¹⁰) because memory is addressed in powers of two; disk manufacturers use 1,000, which is why a “500 GB” drive shows 465 GB in Windows.
  • File permissions on Linux. chmod 755 is octal (base 8, three bits per digit): 7 = 111 = read, write, execute.
  • Bit flags in settings and APIs. A value of 5 meaning “options 1 and 4” is binary 101: each bit is a switch.
  • Negative numbers. Computers store them in “two’s complement”: flip every bit and add one. In 8 bits, −1 is 11111111, which is why an overflowed counter sometimes shows 255 or −1 depending on how it’s read.

Bits, bytes and the units

8 bits = 1 byte, enough for one ASCII character or one colour channel. 16 bits = 65,536 values (a Unicode code unit, a CD audio sample). 32 bits ≈ 4.3 billion (an IPv4 address, older systems’ memory limit). 64 bits ≈ 18 quintillion (modern everything). When someone says “a 32-bit integer overflows at 2,147,483,647”, that is 2³¹ − 1, the largest positive value when one bit is reserved for the sign.

For related number work, the Scientific Calculator handles powers directly, and the Base64 tool is the next step up: Base64 groups bits in sixes instead of fours.

Frequently asked questions

How do I convert binary to decimal quickly?

Write the powers of two (1, 2, 4, 8, 16…) under the bits from right to left and add the ones under a 1.

What is 1111 in decimal?

8 + 4 + 2 + 1 = 15, which is F in hexadecimal.

Why do computers use binary?

Two states (on/off, high/low voltage) are the simplest to build reliably in hardware. Everything else is layered on top.

What is the biggest number in 8 bits?

255 (11111111) for unsigned values, or 127 to −128 if one bit is used for the sign.

Try it now: Binary to Decimal Number Converter

Free, runs in your browser, nothing uploaded, no sign-up.

Open the tool →

Tools for this job

Free, in your browser, no sign-up.

Add a comment Add a comment

Leave a Reply

Your email address will not be published. Required fields are marked *

Submit Comment

Advertisement
Seraphinite AcceleratorOptimized by Seraphinite Accelerator
Turns on site high speed to be attractive for people and search engines.