Binary Calculator

Valid characters: 0-9

Base Systems

Binary (Base 2): 0, 1
Octal (Base 8): 0-7
Decimal (Base 10): 0-9
Hex (Base 16): 0-9, A-F

Understanding Number Systems

What is Binary?

Binary is a base-2 number system that uses only two digits: 0 and 1. It's the fundamental language of computers because electronic circuits can easily represent two states: on (1) and off (0).

Number Systems Comparison

DecimalBinaryOctalHexadecimal
0000
510155
10101012A
15111117F
16100002010
100110010014464
25511111111377FF

Converting Binary to Decimal

Each position in binary represents a power of 2, starting from 2⁰ on the right:

Example: 1101 to Decimal

Position: 3 2 1 0

Binary: 1 1 0 1

Power of 2: 2³ 2² 2¹ 2⁰

Value: 8 + 4 + 0 + 1 = 13

Converting Decimal to Binary

Divide by 2 repeatedly and read the remainders bottom-to-top:

Example: 13 to Binary

13 ÷ 2 = 6 remainder 1 ↑

6 ÷ 2 = 3 remainder 0 |

3 ÷ 2 = 1 remainder 1 |

1 ÷ 2 = 0 remainder 1 |

Read upward: 1101

Why Hexadecimal?

Hexadecimal (hex) is popular in computing because:

  • One hex digit represents exactly 4 binary digits (a nibble)
  • Two hex digits represent 8 bits (a byte): 00 to FF
  • It's much more compact than binary while still easy to convert
  • Common in colors (#FF5733), memory addresses, and programming

Hex Digits

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

Common Prefixes

  • 0b - Binary (0b1010)
  • 0o - Octal (0o12)
  • 0x - Hexadecimal (0xA)

Real-World Applications

  • Colors: #RRGGBB in hexadecimal (e.g., #FF0000 = red)
  • IP Addresses: Sometimes shown in hex
  • Memory: RAM addresses in hexadecimal
  • Permissions: Unix permissions in octal (chmod 755)
  • ASCII: Character codes in hex

Frequently Asked Questions

How do you convert binary to decimal?

Each binary digit represents a power of 2, starting from 2 to the 0 on the right. Add up the values where there's a 1. For example, 1101 = (1x8) + (1x4) + (0x2) + (1x1) = 8 + 4 + 0 + 1 = 13 in decimal.

How do you convert decimal to binary?

Repeatedly divide by 2 and record remainders. Read remainders from bottom to top. For 13: 13/2=6 R1, 6/2=3 R0, 3/2=1 R1, 1/2=0 R1. Reading upward: 1101. Alternatively, subtract the largest powers of 2 that fit.

Why do computers use binary?

Binary (base-2) uses only 0 and 1, which matches the two states of electronic circuits: on/off, high/low voltage. This makes binary naturally suited for digital electronics and makes computer hardware simpler and more reliable.

What is octal and when is it used?

Octal is base-8 using digits 0-7. Each octal digit represents exactly 3 binary digits. It's used in Unix/Linux file permissions (chmod 755) and some older computer systems. It's more compact than binary but less common than hexadecimal today.