Computer Science πŸ‡ΊπŸ‡Έ USA πŸ‡¬πŸ‡§ UK Live Results All 4 Bases
Convert

Binary Calculator

Convert between binary, decimal, hexadecimal, and octal instantly. Perform binary arithmetic operations and see bit representations. Free for computer science students in USA and UK.

Number Base Converter

Live
Enter a number and select its base. The calculator converts to all other bases instantly and shows bit representations.
Enter two binary numbers (0s and 1s only) and choose an operation. Results are shown in binary and decimal.

Conversion Results

β€”
Binary
β€”
Enter a number above to convert
Binary Bit Weights (8-bit)
ON vs OFF Bits

Binary Number System Guide

Guide

Binary Calculator – Complete Guide to Number Systems (USA & UK)

Binary is the fundamental language of computers. Every piece of data β€” text, images, video, programs β€” is stored and processed as sequences of 0s and 1s. Understanding binary, and how it relates to decimal, hexadecimal, and octal, is essential knowledge for computer science students, programmers, and anyone working with digital technology. This free binary calculator converts between all four number bases and performs binary arithmetic operations instantly.

What Is the Binary Number System?

The binary number system is a base-2 positional numeral system using only two digits: 0 and 1. These digits correspond to the two states of a transistor β€” off (0) and on (1). Every computer processor, memory chip, and digital circuit operates on binary logic at the hardware level.

In contrast, the decimal system we use daily is base-10 and uses digits 0–9. Hexadecimal is base-16 and uses 0–9 plus A–F. Octal is base-8 and uses 0–7.

Number SystemBaseDigits UsedCommon Use
Binary20, 1CPU registers, memory, logic gates
Octal80–7Unix file permissions, legacy systems
Decimal100–9Human-readable numbers, everyday maths
Hexadecimal160–9, A–FMemory addresses, colour codes, debugging

How to Convert Binary to Decimal

Each binary digit (bit) represents a power of 2. The rightmost bit is 2⁰ = 1, the next is 2¹ = 2, then 2² = 4, 2³ = 8, and so on. To convert binary to decimal, multiply each bit by its positional value and sum the results.

Example: Convert 1010 1010 (binary) to decimal.

  • 1Γ—128 + 0Γ—64 + 1Γ—32 + 0Γ—16 + 1Γ—8 + 0Γ—4 + 1Γ—2 + 0Γ—1 = 128+32+8+2 = 170

How to Convert Decimal to Binary

Divide the decimal number by 2 repeatedly, recording the remainder at each step. The binary representation is the remainders read from bottom to top.

Example: Convert 42 to binary.

  • 42 Γ· 2 = 21 remainder 0
  • 21 Γ· 2 = 10 remainder 1
  • 10 Γ· 2 = 5 remainder 0
  • 5 Γ· 2 = 2 remainder 1
  • 2 Γ· 2 = 1 remainder 0
  • 1 Γ· 2 = 0 remainder 1
  • Read remainders bottom to top: 101010

Binary Arithmetic

Binary Addition

Binary addition follows four simple rules: 0+0=0, 0+1=1, 1+0=1, 1+1=10 (carry 1). Carrying works just like decimal addition but with base 2.

Binary Subtraction

Binary subtraction uses borrowing just like decimal. In practice, computers perform subtraction using two's complement addition, which avoids dedicated subtraction hardware.

Bitwise Operations

Bitwise operations work on each bit position independently. They are fundamental to programming, encryption, and digital circuit design:

  • AND: output is 1 only if both input bits are 1
  • OR: output is 1 if either input bit is 1
  • XOR: output is 1 if the input bits are different
  • NOT: flips each bit (0 becomes 1, 1 becomes 0)

Two's Complement β€” Negative Numbers in Binary

Computers represent negative integers using two's complement notation. To negate a number in two's complement: invert all bits (one's complement), then add 1. For example, to represent βˆ’42 in 8-bit two's complement: 42 = 00101010, invert = 11010101, add 1 = 11010110.

Two's complement is elegant because addition hardware handles both positive and negative numbers without modification β€” 3 + (βˆ’2) = 3 + 254 (in 8-bit unsigned) produces the correct result of 1 with an ignored carry.

ASCII, Unicode, and Binary

Every text character is stored as a binary number. ASCII assigns 7-bit codes to 128 characters: the letter 'A' is 65 decimal = 01000001 binary. Unicode extends this to cover over 140,000 characters from all the world's writing systems. UTF-8, the dominant encoding on the web, stores ASCII characters in one byte and expands to up to four bytes for other characters.

Computer Memory β€” Bytes, Kilobytes, Megabytes

Memory is measured in multiples of bytes, where 1 byte = 8 bits. The traditional binary prefixes (used in US and UK computing education) are:

UnitValueBytes
1 Kilobyte (KB)2¹⁰1,024 bytes
1 Megabyte (MB)2²⁰1,048,576 bytes
1 Gigabyte (GB)2³⁰1,073,741,824 bytes
1 Terabyte (TB)2⁴⁰~1.1 trillion bytes

IPv4 Addresses and Binary

IPv4 network addresses are 32-bit binary numbers displayed in dotted-decimal notation. The address 192.168.1.1 is stored as 11000000.10101000.00000001.00000001. Subnet masks determine which bits identify the network versus the host.

Binary in UK and US Computing Education

In the United Kingdom, binary representation is covered in GCSE Computer Science (OCR, AQA, Edexcel). Students must convert between binary, denary (decimal), hexadecimal, and sometimes octal. Two's complement, sign-and-magnitude, character encoding (ASCII/Unicode), and binary arithmetic are all examination topics.

In the United States, binary and number system conversions appear in AP Computer Science Principles, AP Computer Science A, and most computer engineering degree programs. The College Board's CSP course covers binary representation of data as a core concept.

History of Binary

The binary system was formalised by Gottfried Wilhelm Leibniz in 1703, who recognised its philosophical elegance and its potential for calculation machines. However, it was George Boole's 1854 work "An Investigation of the Laws of Thought" that laid the algebraic foundation (Boolean algebra) for binary logic circuits. Claude Shannon's 1937 MIT thesis showed how Boolean algebra could be applied to electrical circuits, directly enabling modern computer design. The first electronic computers β€” ENIAC (USA, 1945) and Colossus (UK, 1944) β€” used binary internally.

Frequently Asked Questions

How do you convert binary to decimal?

Multiply each binary digit by 2 raised to its position power (starting from 0 at the right), then sum all values. For example, 1101 = 1Γ—8 + 1Γ—4 + 0Γ—2 + 1Γ—1 = 13. Our binary calculator does this automatically for any number.

What is two's complement?

Two's complement is the method computers use to represent negative integers in binary. To negate a number: flip all bits (one's complement), then add 1. For example, βˆ’5 in 8-bit two's complement is: 5=00000101, flip=11111010, add 1=11111011. This allows the same addition circuits to handle both positive and negative numbers.

What is the difference between binary, octal, and hexadecimal?

Binary (base 2) uses digits 0–1, octal (base 8) uses 0–7, and hexadecimal (base 16) uses 0–9 and A–F. Each octal digit represents exactly 3 binary bits, and each hex digit represents exactly 4 binary bits. This makes octal and hex convenient shorthand for binary data.

What are bitwise operations?

Bitwise operations (AND, OR, XOR, NOT) operate on each corresponding bit of two binary numbers independently. They are used in programming for flags, masks, and optimisations. AND clears bits, OR sets bits, XOR toggles bits, and NOT inverts all bits.

How is binary used in computer memory?

Computer memory (RAM, storage) stores all data as binary. Each memory cell holds one bit (0 or 1). A byte = 8 bits can represent 256 values (0–255). A kilobyte = 1,024 bytes, a megabyte = 1,048,576 bytes. All text, images, video, and programs are ultimately sequences of binary digits.

How do computers represent text in binary?

Text is encoded using character encoding standards. ASCII assigns 7-bit codes to 128 characters ('A' = 65 = 01000001). Unicode/UTF-8 extends this to over 140,000 characters. Each character is stored as a specific binary pattern. This is covered in UK GCSE Computer Science and US AP Computer Science.

Is binary taught in UK schools?

Yes. Binary is a core topic in GCSE Computer Science in England, Wales, and Northern Ireland. Specifications from AQA, OCR, and Edexcel all require students to convert between binary, denary, and hexadecimal, perform binary arithmetic, understand two's complement, and know about character encoding (ASCII/Unicode).

What is an IPv4 address in binary?

An IPv4 address is a 32-bit binary number shown in dotted-decimal notation. For example, 192.168.1.1 = 11000000.10101000.00000001.00000001 in binary. Subnet masks use binary to define network and host portions of an address. Understanding binary is essential for networking and cybersecurity professionals.

⚠️ Disclaimer

Important

This calculator handles non-negative integers for base conversions. Two's complement and signed representations use JavaScript's standard integer handling. For very large numbers, precision may be limited by JavaScript's 53-bit safe integer range.

Binary
β€”