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.
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.
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 System | Base | Digits Used | Common Use |
|---|---|---|---|
| Binary | 2 | 0, 1 | CPU registers, memory, logic gates |
| Octal | 8 | 0β7 | Unix file permissions, legacy systems |
| Decimal | 10 | 0β9 | Human-readable numbers, everyday maths |
| Hexadecimal | 16 | 0β9, AβF | Memory addresses, colour codes, debugging |
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.
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.
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 uses borrowing just like decimal. In practice, computers perform subtraction using two's complement addition, which avoids dedicated subtraction hardware.
Bitwise operations work on each bit position independently. They are fundamental to programming, encryption, and digital circuit design:
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.
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.
Memory is measured in multiples of bytes, where 1 byte = 8 bits. The traditional binary prefixes (used in US and UK computing education) are:
| Unit | Value | Bytes |
|---|---|---|
| 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 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.
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.
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.
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.
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.
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.
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.
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.
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.
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).
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.
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.