Binary Calculator - Convert Binary to Decimal, Hex, Octal | Free Online Binary Converter

Input

Enter the number you want to convert

Select the number system of your input

Quick Reference

Number Systems

  • Binary (Base 2): Uses digits 0-1
  • Octal (Base 8): Uses digits 0-7
  • Decimal (Base 10): Uses digits 0-9
  • Hexadecimal (Base 16): Uses 0-9, A-F

Bitwise Operations

  • AND: Both bits must be 1
  • OR: At least one bit must be 1
  • XOR: Bits must be different
  • NOT: Inverts all bits

Understanding Binary Numbers and Number Systems

What is Binary?

Binary (base-2) is the fundamental number system used in computing and digital electronics. Unlike the decimal system we use daily (base-10), binary uses only two digits: 0 and 1. This corresponds perfectly to the two states of electronic circuits: off (0) and on (1). Every piece of data in a computer—from numbers and text to images and programs—is ultimately represented in binary.

Number System Conversion Guide

Binary to Decimal Conversion

To convert a binary number to decimal, multiply each digit by 2 raised to its position (counting from right to left, starting at 0) and sum the results. For example:

Binary: 1011

= (1 × 2³) + (0 × 2²) + (1 × 2¹) + (1 × 2⁰)

= (1 × 8) + (0 × 4) + (1 × 2) + (1 × 1)

= 8 + 0 + 2 + 1

= 11 (decimal)

Decimal to Binary Conversion

To convert decimal to binary, repeatedly divide the number by 2 and record the remainders. The binary number is formed by reading the remainders from bottom to top:

Decimal: 13

13 ÷ 2 = 6 remainder 1

6 ÷ 2 = 3 remainder 0

3 ÷ 2 = 1 remainder 1

1 ÷ 2 = 0 remainder 1

Binary: 1101 (reading remainders bottom to top)

Hexadecimal and Octal Systems

Hexadecimal (base-16) and octal (base-8) are commonly used in programming because they provide more compact representations of binary numbers:

  • Hexadecimal: Uses digits 0-9 and letters A-F. Each hex digit represents exactly 4 binary digits. Example: Binary 11111111 = Hex FF = Decimal 255
  • Octal: Uses digits 0-7. Each octal digit represents exactly 3 binary digits. Example: Binary 111101 = Octal 75 = Decimal 61
  • Use Cases: Hex is used for memory addresses, color codes (#FF0000), and byte values. Octal is used in Unix file permissions (chmod 755).

Binary Arithmetic Operations

Binary Addition

Binary addition follows these rules:

0 + 0 = 0

0 + 1 = 1

1 + 0 = 1

1 + 1 = 10 (0 with carry of 1)

1 + 1 + 1 = 11 (1 with carry of 1)

Example: Adding 1011 + 0110 = 10001. Start from the rightmost bit and work left, carrying when necessary, just like decimal addition but with base-2 rules.

Binary Subtraction

Binary subtraction can be performed using borrowing (similar to decimal) or by using two's complement for negative numbers. The borrowing rules are:

0 - 0 = 0

1 - 0 = 1

1 - 1 = 0

0 - 1 = 1 (with borrow)

Bitwise Operations Explained

Bitwise operations work on individual bits and are fundamental in low-level programming, hardware interfacing, and optimization:

AND Operation (&)

Returns 1 only if both bits are 1. Used for masking and checking specific bits.

1010 AND 1100 = 1000

OR Operation (|)

Returns 1 if at least one bit is 1. Used for setting specific bits.

1010 OR 1100 = 1110

XOR Operation (^)

Returns 1 only if bits are different. Used for toggling and encryption.

1010 XOR 1100 = 0110

NOT Operation (~)

Inverts all bits (0 becomes 1, 1 becomes 0). Used for complementing values.

NOT 1010 = 0101

Practical Applications of Binary

In Computer Programming

  • Flags and Bitmasks: Using single bits to represent boolean states efficiently. For example, file permissions in Unix use 9 bits for read, write, execute permissions for owner, group, and others.
  • Performance Optimization: Bitwise operations are significantly faster than arithmetic operations. Multiplying by 2 using left shift (x << 1) is faster than (x * 2).
  • Color Representation: Colors in web and graphics are often represented in hexadecimal (e.g., #FF5733 represents RGB values in hex: FF=255 red, 57=87 green, 33=51 blue).
  • Network Protocols: IP addresses, subnet masks, and packet headers use binary representation for efficient routing and processing.

In Digital Electronics

Binary forms the foundation of digital circuits. Logic gates (AND, OR, NOT, XOR, NAND, NOR) perform binary operations on electrical signals. These gates combine to create complex circuits like adders, multiplexers, and memory units. Understanding binary is essential for hardware design, embedded systems programming, and digital signal processing.

💡 Pro Tips for Working with Binary

  • Powers of Two: Memorize powers of 2 up to 2¹⁶ (65536) for quick mental conversions
  • Hex Shortcuts: Convert binary to hex by grouping 4 bits at a time (nibbles)
  • Practice: Try converting your age, birth year, or favorite numbers to binary
  • Debugging: Use binary/hex representation when debugging low-level code or hardware
  • Bit Counting: The number of 1s in a binary number is called "population count" or "Hamming weight"

Common Binary Patterns

DecimalBinaryOctalHexadecimalCommon Use
0000000Zero, false, off
1000111One, true, on
81000108Byte boundary
15111117FNibble all bits set
25511111111377FFMax unsigned byte

🎓 Learning Resources

For deeper understanding of binary and computer arithmetic:

  • Visit MIT OpenCourseWare for computer science fundamentals
  • Check Khan Academy for free tutorials on binary and number systems
  • Practice bitwise operations on LeetCode and HackerRank
  • Read IEEE and ACM publications for advanced computer arithmetic topics

Related Calculators