Convert between binary, decimal, hexadecimal and octal instantly. Step-by-step conversion shown for every result.
Computers store and process all data using binary — the base-2 number system where every value is expressed using only 0s and 1s. While humans naturally use decimal (base 10), digital systems use binary because electronic circuits have two stable states: on (1) and off (0). Understanding binary and how to convert between number bases is fundamental to computer science, programming, digital electronics and networking. This converter handles the four most common number bases: decimal (base 10), binary (base 2), hexadecimal (base 16) and octal (base 8), and shows step-by-step working for every conversion.
In binary, each digit position represents a power of 2, starting from 2^0 = 1 on the right and doubling with each position to the left: 1, 2, 4, 8, 16, 32, 64, 128 and so on. A binary number is read by summing the powers of 2 corresponding to positions where a 1 appears. Binary 1101 = 1x8 + 1x4 + 0x2 + 1x1 = 13. Binary 11111111 = 128+64+32+16+8+4+2+1 = 255, the maximum value of one byte. Binary 10000000 = 128. The number of values representable by n bits is 2^n: 1 bit = 2 values, 8 bits = 256 values, 16 bits = 65,536 values, 32 bits = 4,294,967,296 values. Use our scientific calculator for powers-of-2 calculations and our square root calculator for related mathematical operations.
| Decimal | Binary | Hexadecimal | Octal | Bits Needed |
|---|---|---|---|---|
| 0 | 0 | 0 | 0 | 1 |
| 1 | 1 | 1 | 1 | 1 |
| 7 | 111 | 7 | 7 | 3 |
| 10 | 1010 | A | 12 | 4 |
| 15 | 1111 | F | 17 | 4 |
| 16 | 10000 | 10 | 20 | 5 |
| 42 | 101010 | 2A | 52 | 6 |
| 100 | 1100100 | 64 | 144 | 7 |
| 127 | 1111111 | 7F | 177 | 7 |
| 255 | 11111111 | FF | 377 | 8 |
Hexadecimal (base 16) uses digits 0-9 and letters A through F, where A=10, B=11, C=12, D=13, E=14, F=15. The key advantage of hex over binary is compactness: one hex digit represents exactly 4 binary bits, and two hex digits represent exactly one byte (8 bits). This makes hex ideal for expressing memory addresses, colour codes, byte-level data and machine code. Web colour codes like #FF5733 represent RGB values: FF=255 red, 57=87 green, 33=51 blue, each channel being one byte (0-255). Memory addresses in 64-bit systems are expressed as hex values like 0x7FFD3A2B4C10. IP addresses in IPv6 use hex: 2001:0db8:85a3:0000:0000:8a2e:0370:7334. Error codes in Windows crash screens (BSOD) are hex values. Converting hex to binary mentally is straightforward: replace each hex digit with its 4-bit binary equivalent. FF = 1111 1111, 2A = 0010 1010. Use our percentage calculator to calculate memory usage percentages and our ratio calculator for bit-to-byte ratios.
To convert any positive decimal integer to binary, repeatedly divide by 2 and collect the remainders. Each remainder is either 0 or 1, which become the binary digits read from bottom to top. Example: convert 45 to binary. 45 / 2 = 22 remainder 1. 22 / 2 = 11 remainder 0. 11 / 2 = 5 remainder 1. 5 / 2 = 2 remainder 1. 2 / 2 = 1 remainder 0. 1 / 2 = 0 remainder 1. Reading remainders bottom to top: 101101. Verify: 32+8+4+1 = 45. This method works for any positive integer regardless of size. For negative numbers, computers use two's complement representation: find the binary of the positive value, flip all bits, then add 1. The two's complement of 45 (in 8 bits) is 11010011, which represents -45 in signed 8-bit arithmetic.
| Hex Digit | Decimal | Binary (4 bits) | Hex Digit | Decimal | Binary |
|---|---|---|---|---|---|
| 0 | 0 | 0000 | 8 | 8 | 1000 |
| 1 | 1 | 0001 | 9 | 9 | 1001 |
| 2 | 2 | 0010 | A | 10 | 1010 |
| 3 | 3 | 0011 | B | 11 | 1011 |
| 4 | 4 | 0100 | C | 12 | 1100 |
| 5 | 5 | 0101 | D | 13 | 1101 |
| 6 | 6 | 0110 | E | 14 | 1110 |
| 7 | 7 | 0111 | F | 15 | 1111 |
Binary arithmetic follows the same rules as decimal arithmetic but with only two digits. Binary addition: 0+0=0, 0+1=1, 1+0=1, 1+1=10 (0 carry 1), 1+1+1=11 (1 carry 1). Example: 1011 + 0110 = 10001 (11 + 6 = 17 in decimal). Overflow occurs when the result requires more bits than the register width allows. An 8-bit register can hold values 0-255 (unsigned) or -128 to 127 (signed). If an 8-bit addition produces a result greater than 255, the extra bit is discarded and the result wraps around — this is integer overflow, a common source of software bugs. The classic example: 255 + 1 in 8-bit unsigned arithmetic = 0 (not 256), because 11111111 + 00000001 = 100000000, and the 9th bit is discarded leaving 00000000. Understanding binary arithmetic is essential for systems programming, embedded systems and security. Use our fraction calculator for fractional number work and our scientific calculator for scientific notation and powers.
Octal (base 8) uses digits 0 through 7. Each octal digit represents exactly 3 binary bits, making it another compact representation of binary data. Octal was widely used in early computing systems including the DEC PDP-8 and early Unix systems because early word sizes (12, 24, 36 bits) divided evenly by 3. Today octal is primarily used in Unix and Linux file permission notation. The chmod command uses octal: 755 means 111 101 101 in binary = rwxr-xr-x (owner can read/write/execute, group and others can read/execute). 644 = 110 100 100 = rw-r--r-- (owner reads/writes, others read only). 777 = 111 111 111 = rwxrwxrwx (everyone full access). To convert octal to binary, replace each octal digit with its 3-bit binary equivalent: octal 7 = 111, octal 5 = 101, octal 3 = 011. Octal 753 = 111 101 011 in binary = decimal 491.
A bit (binary digit) is the smallest unit of digital information, holding a value of 0 or 1. A byte is 8 bits and can represent 256 distinct values. All digital data — text, images, audio, video, programs — is ultimately stored as sequences of bytes. The standard data units and their binary relationships: 1 byte = 8 bits. 1 kilobyte (KB) = 1,024 bytes = 2^10 bytes. 1 megabyte (MB) = 1,048,576 bytes = 2^20 bytes. 1 gigabyte (GB) = 1,073,741,824 bytes = 2^30 bytes. 1 terabyte (TB) = 2^40 bytes. The use of 1,024 rather than 1,000 as the multiplier is because binary powers of 2 nearest to 1,000 is 2^10 = 1,024. Hard drive manufacturers use 1,000-byte kilobytes (decimal) while operating systems use 1,024-byte kibibytes (binary), which is why a drive labelled 500GB shows as approximately 465GB in Windows. Use our percentage calculator to calculate the percentage difference between decimal and binary storage sizes.
Binary encoding underlies every piece of digital information you interact with. ASCII (American Standard Code for Information Interchange) encodes each text character as a 7-bit binary number: the letter 'A' is 1000001 (decimal 65), 'a' is 1100001 (97), '0' is 0110000 (48). UTF-8, the dominant text encoding standard on the web, extends ASCII to encode over 1.1 million Unicode characters using 1-4 bytes per character. Image files store pixel colour values as binary: each pixel in an RGB image uses 3 bytes (24 bits) storing red, green and blue values from 0-255 each. A 1920x1080 uncompressed image requires 1920 x 1080 x 3 = 6,220,800 bytes (about 6MB) before compression. Audio files store amplitude samples as binary: CD audio uses 16 bits per sample at 44,100 samples per second per channel. Understanding binary is the foundation of understanding how every digital system from your calculator to your phone actually stores and processes information. Our scientific calculator handles powers-of-two calculations for computing tasks, and our percentage calculator is useful for calculating storage efficiency ratios between compressed and uncompressed formats.
Bitwise operations are fundamental to low-level programming and are supported in virtually every programming language. The AND operator (&) returns 1 only when both bits are 1: 1100 AND 1010 = 1000. OR (|) returns 1 when either bit is 1: 1100 OR 1010 = 1110. XOR (^) returns 1 when bits differ: 1100 XOR 1010 = 0110. NOT (~) flips all bits. Left shift (<<) multiplies by powers of 2: 0011 << 1 = 0110 (3 x 2 = 6). Right shift (>>) divides by powers of 2: 1100 >> 1 = 0110 (12 / 2 = 6). These operations are used for tasks including setting flags in configuration bytes, masking specific bits in hardware registers, fast multiplication and division, and implementing cryptographic algorithms. Understanding binary representation is a prerequisite for understanding how these operations work at the hardware level. Our scientific calculator supports scientific notation for large binary values and our square root calculator is useful for related mathematical computations in computer science problems.