Binary Converter Calculator

Convert between binary (base 2), decimal (base 10), octal (base 8), and hexadecimal (base 16) number systems instantly.

Conversion Results

Converted
Binary
-
Base 2
Decimal
-
Base 10
Octal
-
Base 8
Hexadecimal
-
Base 16

Conversion Steps

Key Takeaways

  • Binary (Base 2) uses only 0 and 1 - the foundation of all digital computing
  • Hexadecimal (Base 16) provides a compact way to represent binary - each hex digit equals 4 binary digits
  • Octal (Base 8) groups binary digits into sets of 3, commonly used in Unix file permissions
  • All number systems represent the same values - just in different notations
  • Understanding base conversion is essential for programming, computer science, and digital electronics

What Are Number Bases? A Complete Explanation

A number base (also called a radix) determines how many unique digits a numbering system uses and how positional values are calculated. The base you're most familiar with is decimal (base 10), which uses digits 0-9. However, computers and digital systems frequently use binary (base 2), octal (base 8), and hexadecimal (base 16) for various purposes.

In any positional number system, each digit's value depends on its position. In decimal, the rightmost digit represents ones (10^0), the next represents tens (10^1), then hundreds (10^2), and so on. The same principle applies to all bases - in binary, positions represent powers of 2: ones (2^0), twos (2^1), fours (2^2), eights (2^3), and so forth.

The Same Number in Different Bases

Decimal 255
Binary 11111111
Octal 377
Hexadecimal FF

Understanding Binary: The Language of Computers

Binary (base 2) is the fundamental language of all digital computers. It uses only two digits: 0 and 1, which correspond to the two states of electronic switches - off and on. Every piece of data in your computer, from text and images to videos and software, is ultimately represented as sequences of binary digits (bits).

Each position in a binary number represents a power of 2. Reading from right to left: the first position is 2^0 (1), the second is 2^1 (2), the third is 2^2 (4), the fourth is 2^3 (8), and so on. To convert binary to decimal, multiply each digit by its positional value and sum the results.

How to Convert Binary to Decimal (Step-by-Step)

1

Write Out Position Values

For binary 1011, write the powers of 2 from right to left: 2^3=8, 2^2=4, 2^1=2, 2^0=1

2

Multiply Each Digit by Its Position Value

1x8 + 0x4 + 1x2 + 1x1 = 8 + 0 + 2 + 1

3

Sum All Values

8 + 0 + 2 + 1 = 11 in decimal

Pro Tip: Quick Binary Powers of 2

Memorize the first 8 powers of 2: 1, 2, 4, 8, 16, 32, 64, 128. This makes mental binary-to-decimal conversion much faster. For example, binary 10000000 is instantly recognizable as 128.

Hexadecimal: The Programmer's Friend

Hexadecimal (base 16) uses 16 symbols: 0-9 and A-F (where A=10, B=11, C=12, D=13, E=14, F=15). Hexadecimal is widely used in programming because it provides a compact way to represent binary data. Each hexadecimal digit corresponds to exactly 4 binary digits (a "nibble"), making conversion between hex and binary straightforward.

You'll encounter hexadecimal in many contexts: color codes in web design (#FF5733), memory addresses in programming (0x7FFE), MAC addresses in networking (00:1A:2B:3C:4D:5E), and error codes in system debugging. Understanding hex is essential for any aspiring programmer or IT professional.

Decimal Binary Hexadecimal Octal
0000000
1000111
2001022
3001133
4010044
5010155
6011066
7011177
81000810
91001911
101010A12
111011B13
121100C14
131101D15
141110E16
151111F17
16100001020

Octal: Unix and File Permissions

Octal (base 8) uses digits 0-7 and groups binary digits into sets of three. While less common than hexadecimal in modern programming, octal remains important in Unix/Linux systems for representing file permissions. The chmod command, for example, uses octal notation where 7=rwx (read/write/execute), 5=r-x (read/execute), and 4=r-- (read only).

Understanding Unix Permissions

The permission chmod 755 means: Owner (7=111=rwx), Group (5=101=r-x), Others (5=101=r-x). Each digit represents 3 bits controlling read, write, and execute permissions respectively.

Real-World Applications of Number Base Conversion

1. Web Development and Color Codes

HTML and CSS use hexadecimal color codes. The color #FF5733 breaks down to: FF (255 red), 57 (87 green), 33 (51 blue). Understanding hex helps you manually adjust colors and understand how RGB values work.

2. Computer Memory and Addresses

Memory addresses are displayed in hexadecimal because it's more compact than binary. A 32-bit address like 0x7FFFFFFF is much easier to read than its binary equivalent of 32 ones and zeros.

3. Network Configuration

MAC addresses, IPv6 addresses, and various network protocols use hexadecimal notation. IP subnet masks are often visualized in binary to understand which bits represent the network versus host portions.

4. Digital Electronics

Hardware engineers work directly with binary when designing circuits, logic gates, and microprocessors. Understanding binary arithmetic is fundamental to digital design.

5. Data Encoding

Base64 encoding, commonly used for email attachments and data URLs, is another example of base conversion - converting binary data to a base-64 representation using alphanumeric characters.

Common Conversion Mistakes

Mistake 1: Forgetting that hex uses letters A-F. The value "1A" is valid hex but "1G" is not.
Mistake 2: Confusing octal and decimal. The octal number 10 equals decimal 8, not 10.
Mistake 3: Not padding binary numbers. When converting to hex, group binary digits from right to left, adding leading zeros if needed.

Advanced Conversion Techniques

Binary to Hexadecimal Shortcut

Group binary digits into sets of 4 from right to left, then convert each group to its hex equivalent. For example: 11010110 becomes 1101 0110, which is D6 in hex.

Hexadecimal to Binary Shortcut

Replace each hex digit with its 4-bit binary equivalent. For example: 3F becomes 0011 1111 (3=0011, F=1111).

Decimal to Binary Using Division

Repeatedly divide by 2 and record remainders. Read the remainders bottom-to-top. For 25: 25/2=12 R1, 12/2=6 R0, 6/2=3 R0, 3/2=1 R1, 1/2=0 R1. Result: 11001.

Pro Tip: Hex Color Shorthand

In CSS, you can use 3-digit hex colors when both digits are the same: #FF5533 can be written as #F53. The browser expands each digit to two identical digits.

Binary Arithmetic Basics

Understanding binary arithmetic is crucial for computer science. Here are the basic operations:

  • Binary Addition: 0+0=0, 0+1=1, 1+0=1, 1+1=10 (carry the 1)
  • Binary Subtraction: Uses two's complement for negative numbers
  • Binary Multiplication: Similar to decimal, but simpler since you only multiply by 0 or 1
  • Binary Division: Repeated subtraction, similar to long division

Number Representations in Programming

Different programming languages use different prefixes to indicate number bases:

  • Binary: 0b1010 (Python, JavaScript, C++), %1010 (Assembly)
  • Octal: 0o12 (Python), 012 (C, JavaScript - deprecated in strict mode)
  • Hexadecimal: 0xFF (most languages), $FF (Assembly, Pascal)
  • Decimal: No prefix needed - just write the number

Bit Manipulation and Bitwise Operations

Understanding binary enables powerful bitwise operations that manipulate individual bits within a number. These operations are fundamental to low-level programming, encryption algorithms, graphics processing, and performance optimization.

Common Bitwise Operations

  • AND (&): Returns 1 only if both bits are 1. Used for masking specific bits. Example: 1010 & 1100 = 1000
  • OR (|): Returns 1 if either bit is 1. Used for setting bits. Example: 1010 | 1100 = 1110
  • XOR (^): Returns 1 if bits are different. Used in encryption and toggling. Example: 1010 ^ 1100 = 0110
  • NOT (~): Inverts all bits. Example: ~1010 = 0101 (in 4 bits)
  • Left Shift (<<): Shifts bits left, multiplying by 2. Example: 0011 << 2 = 1100 (3 becomes 12)
  • Right Shift (>>): Shifts bits right, dividing by 2. Example: 1100 >> 2 = 0011 (12 becomes 3)

Pro Tip: Powers of 2 Shortcuts

Left-shifting by n is equivalent to multiplying by 2^n, and right-shifting by n is equivalent to dividing by 2^n (integer division). This is much faster than multiplication/division in compiled code.

Understanding Data Sizes and Storage

Binary directly impacts how computers store and process data. Understanding the relationship between bits, bytes, and larger units is essential for working with memory, storage, and data transmission.

Unit Size in Bits Range (Unsigned) Common Usage
Bit10-1Boolean flags, binary states
Nibble40-15Single hex digit
Byte80-255Characters, small integers
Word (16-bit)160-65,535Unicode characters
Double Word (32-bit)320-4.29 billionIPv4 addresses, integers
Quad Word (64-bit)640-18.4 quintillionMemory addresses, large integers

The History of Number Systems

The use of different number bases has a rich history spanning thousands of years. Understanding this history helps contextualize why we use specific systems today.

Ancient civilizations used various bases. The Babylonians used base-60 (sexagesimal), which is why we have 60 seconds in a minute and 360 degrees in a circle. The Mayans used base-20, counting on both fingers and toes. The ancient Egyptians and Romans used different symbolic systems altogether.

Decimal (base 10) became dominant because humans have 10 fingers, making it natural for counting. The Hindu-Arabic numeral system (0-9) that we use today spread from India through the Arabic world to Europe during the Middle Ages, revolutionizing mathematics and commerce.

Binary was formalized by Gottfried Wilhelm Leibniz in 1679, who recognized its elegance and connection to philosophy (true/false, existence/non-existence). However, it wasn't until the 20th century that Claude Shannon's work on digital circuits and Boolean algebra made binary practical for computing.

Why ASCII Uses 7 Bits

The ASCII character encoding standard uses 7 bits (128 characters) because early teletype machines used 7-bit codes. The 8th bit was often used for parity checking (error detection). This historical decision influences computing to this day, with UTF-8 designed to be backward-compatible with ASCII.

Unicode, Character Encoding, and Binary

Text in computers is stored as binary-encoded numbers. Understanding how characters map to binary is crucial for handling international text, debugging encoding issues, and working with APIs.

  • ASCII (7-bit): 128 characters covering basic English letters, numbers, and symbols. 'A' = 65 = 01000001 in binary
  • Extended ASCII (8-bit): 256 characters, adding accented letters and special symbols
  • UTF-8 (variable 1-4 bytes): Backward-compatible with ASCII, efficiently encodes the entire Unicode range (1.1 million+ characters)
  • UTF-16 (2 or 4 bytes): Used internally by Java, JavaScript, and Windows. Each character is at least 16 bits

When you see garbled text like "caf?" instead of "cafe" with an accent, it's usually a mismatch between how bytes were encoded (UTF-8) and decoded (Latin-1 or ASCII). Understanding binary helps diagnose these issues.

Frequently Asked Questions

Computers use binary because electronic circuits have two stable states: on (high voltage) and off (low voltage). This two-state system is extremely reliable and easy to implement in hardware. Detecting only two states (0 and 1) is much less error-prone than trying to distinguish between 10 different voltage levels for decimal.

An 8-bit unsigned integer can store values from 0 to 255 (2^8 - 1 = 255). In binary, this is 11111111. If signed (two's complement), the range is -128 to 127. The number of distinct values is always 2^n where n is the number of bits.

Modern computers use two's complement representation. To get -5 in 8-bit binary: (1) Write +5 as 00000101, (2) Flip all bits to get 11111010, (3) Add 1 to get 11111011. This representation allows the same hardware circuits to perform both addition and subtraction.

A bit is a single binary digit (0 or 1). A byte is 8 bits. Bytes are the standard unit for measuring data storage. One kilobyte (KB) is 1,024 bytes, one megabyte (MB) is 1,024 KB, and one gigabyte (GB) is 1,024 MB.

Hexadecimal is popular because each hex digit represents exactly 4 binary digits, making conversion trivial. A 32-bit value that would be 32 characters in binary is only 8 characters in hex. It's human-readable enough while still closely representing the underlying binary data.

Binary fractions use negative powers of 2 after a binary point. For example, 0.101 in binary = 1x(1/2) + 0x(1/4) + 1x(1/8) = 0.5 + 0 + 0.125 = 0.625 in decimal. Computers use floating-point representation (IEEE 754) for decimal fractions.

Octal is primarily used in Unix/Linux file permissions (chmod 755, 644, etc.). Each octal digit represents 3 bits, which maps perfectly to the read-write-execute permission triplet. While less common than hex, octal occasionally appears in older documentation and embedded systems.

Memorize the 4-bit binary equivalents for 0-F. Then, for hex-to-binary, replace each hex digit with its 4 bits. For binary-to-hex, group bits into fours from right to left and convert each group. Example: A3 = 1010 0011, and 11011110 = DE.