Binary Calculator
Quick Answer
Binary is a base-2 number system used by digital computers, where every value is represented using only 0 and 1. This calculator converts binary to decimal, hexadecimal, and octal (and back), and performs binary addition, subtraction, multiplication, and division. For example, 1010 in binary equals 10 in decimal.
Also searched as: binary, binary calculator
Number Base Converter
Enter a value in any field. All others update automatically.
Binary Arithmetic
Result (Binary)
11000
Result (Decimal)
24
How Binary Numbers Work
Binary is a base-2 positional number system that represents all values using only two digits: 0 and 1. It is the foundational language of all modern digital computing, from smartphones to supercomputers. According to the Institute of Electrical and Electronics Engineers (IEEE), binary representation underpins every digital standard in use today, including IEEE 754 for floating-point arithmetic and IEEE 802 for networking protocols. Every file, image, video, and program on your computer is ultimately stored and processed as sequences of binary digits (bits).
This calculator provides two essential tools: a number base converter that instantly translates between binary (base 2), decimal (base 10), hexadecimal (base 16), and octal (base 8), and a binary arithmetic engine that performs addition, subtraction, and multiplication on binary numbers. These operations are fundamental to computer science coursework, programming, network administration, and digital electronics. For focused binary-to-decimal conversion with step-by-step breakdown, see our dedicated binary to decimal calculator.
How Number Base Conversion Is Calculated
Number base conversion uses positional notation, where each digit's value depends on its position and the base of the number system. The general formula for converting any base to decimal is:
Decimal Value = Sum of (digit x base^position), where position starts at 0 from the rightmost digit.
- Binary to Decimal: Multiply each bit by 2 raised to its position and sum. Example: 101010 = 1x32 + 0x16 + 1x8 + 0x4 + 1x2 + 0x1 = 42.
- Decimal to Binary: Repeatedly divide by 2, recording remainders bottom-to-top. Example: 42/2=21r0, 21/2=10r1, 10/2=5r0, 5/2=2r1, 2/2=1r0, 1/2=0r1 = 101010.
- Binary to Hexadecimal: Group bits in sets of 4 from right to left, then convert each group. Example: 0010 1010 = 2A in hex.
- Binary to Octal: Group bits in sets of 3 from right to left, then convert each group. Example: 101 010 = 52 in octal.
Worked example: Convert decimal 255 to all bases. Binary: 11111111 (eight 1s). Hexadecimal: FF (15x16 + 15 = 255). Octal: 377 (3x64 + 7x8 + 7 = 255). This value is significant because 255 is the maximum value of an unsigned 8-bit byte, making it the upper limit for RGB color channels in web development (hence colors like #FFFFFF for white).
Key Terms You Should Know
Bit: The smallest unit of data in computing, representing a single binary digit (0 or 1). All digital information is ultimately composed of bits. The term was coined by mathematician John Tukey in 1947.
Byte: A group of 8 bits, capable of representing 256 different values (0-255 unsigned, or -128 to 127 signed). One byte can represent a single ASCII character, such as the letter 'A' (01000001 in binary, 65 in decimal).
Hexadecimal (Hex): A base-16 number system using digits 0-9 and letters A-F (where A=10 through F=15). Hex is widely used because each hex digit maps to exactly 4 binary bits, making it a compact human-readable representation of binary data. Web colors (#FF5733), memory addresses (0x7FFF), and MAC addresses (00:1A:2B:3C:4D:5E) all use hexadecimal. Use our hex calculator for dedicated hexadecimal operations.
Octal: A base-8 number system using digits 0-7, where each digit maps to exactly 3 binary bits. Octal is primarily used in Unix/Linux file permissions (e.g., chmod 755) and some legacy computing contexts.
Two's complement: The standard method for representing negative numbers in binary. To negate a binary number, invert all bits (0 becomes 1, 1 becomes 0) and add 1. For example, in 8-bit two's complement, -42 is represented as 11010110 (invert 00101010 to get 11010101, then add 1).
Number Systems at a Glance
Here is how the same values are represented across the four number systems supported by this calculator:
| Decimal | Binary | Hexadecimal | Octal | Significance |
|---|---|---|---|---|
| 0 | 0 | 0 | 0 | Zero / null / false |
| 10 | 1010 | A | 12 | Common tutorial example |
| 42 | 101010 | 2A | 52 | ASCII asterisk (*) |
| 127 | 1111111 | 7F | 177 | Max signed 8-bit integer |
| 255 | 11111111 | FF | 377 | Max unsigned byte / RGB max |
| 1024 | 10000000000 | 400 | 2000 | 1 kilobyte (KiB) |
| 65535 | 1111111111111111 | FFFF | 177777 | Max unsigned 16-bit integer |
Practical Examples
Example 1 -- Web Color Conversion: The hex color #1A56DB (the primary blue used on this website) converts to RGB values of R=26, G=86, B=219 in decimal. In binary: R=00011010, G=01010110, B=11011011. Understanding this conversion is essential for web developers working with CSS color values and image processing algorithms.
Example 2 -- IP Address in Binary: The IP address 192.168.1.1 is actually four 8-bit binary numbers: 11000000.10101000.00000001.00000001. Network engineers use binary representation to calculate subnet masks and determine which portion of an IP address identifies the network versus the host. Our IP subnet calculator uses these binary operations internally.
Example 3 -- Binary Addition in Computing: Adding binary 1011 (11 in decimal) and 1101 (13 in decimal): starting from the right, 1+1=10 (write 0 carry 1), 1+0+1=10 (write 0 carry 1), 0+1+1=10 (write 0 carry 1), 1+1+1=11 (write 1 carry 1), carry=1. Result: 11000 = 24 in decimal. This is exactly how a CPU's arithmetic logic unit (ALU) performs addition at the hardware level.
Tips for Working with Binary Numbers
- Memorize powers of 2. Knowing that 2^0=1, 2^1=2, 2^2=4, 2^3=8, 2^4=16, 2^5=32, 2^6=64, 2^7=128, 2^8=256, 2^10=1024, and 2^16=65536 makes mental binary-to-decimal conversion much faster.
- Use hex as a shorthand for binary. Every hexadecimal digit maps to exactly 4 binary bits: 0=0000, 1=0001, ..., 9=1001, A=1010, B=1011, C=1100, D=1101, E=1110, F=1111. Programmers almost always write binary values in hex form because it is 4 times more compact.
- Group binary digits in sets of 4 or 8. Writing 01011010 is much easier to read than 1011010. Leading zeros clarify byte boundaries and prevent misreading values.
- Use prefix notation to avoid ambiguity. Binary values are prefixed with 0b (e.g., 0b1010), hexadecimal with 0x (e.g., 0xFF), and octal with 0o or a leading zero (e.g., 0o52). This is the standard in programming languages like Python, JavaScript, C, and Java.
- Practice with ASCII codes. The ASCII character 'A' is 65 in decimal, 41 in hex, and 01000001 in binary. Working through the ASCII table builds intuition for number base relationships.
Frequently Asked Questions
What is binary and why do computers use it?
Binary is a base-2 number system that uses only two digits: 0 and 1. Computers use binary because electronic circuits have two natural voltage states -- high (on/1) and low (off/0) -- making binary the most reliable way to represent and process data electrically. Every transistor in a CPU acts as a tiny switch that is either on or off, and modern processors contain billions of these switches. Complex data like text, images, and video are all encoded as patterns of binary digits. The binary number 1010 represents 1x8 + 0x4 + 1x2 + 0x1 = 10 in decimal, following the same positional notation principle as our base-10 system.
How do you convert binary to decimal?
To convert binary to decimal, multiply each binary digit (bit) by 2 raised to the power of its position, counting from right to left starting at position 0, then sum all results. For example, binary 1101 = 1x2^3 + 1x2^2 + 0x2^1 + 1x2^0 = 8 + 4 + 0 + 1 = 13 in decimal. For larger numbers, work through each bit systematically: binary 11010110 = 128 + 64 + 0 + 16 + 0 + 4 + 2 + 0 = 214. Our binary to decimal calculator shows this step-by-step breakdown for any input.
How do you add binary numbers?
Binary addition follows the same column-by-column process as decimal addition, but with base-2 rules: 0+0=0, 0+1=1, 1+0=1, 1+1=10 (write 0 and carry 1), and 1+1+1=11 (write 1 and carry 1). For example, adding 1011 (11) and 1101 (13): rightmost column 1+1=10 (write 0 carry 1), next 1+0+1=10 (write 0 carry 1), next 0+1+1=10 (write 0 carry 1), next 1+1+1=11 (write 1 carry 1), final carry=1. Result: 11000 = 24 in decimal. This is exactly how a computer's arithmetic logic unit performs addition at the hardware level.
How do you convert decimal to hexadecimal?
Repeatedly divide the decimal number by 16 and record the remainders, then read remainders from bottom to top. Remainders 10-15 are written as A-F. For example, converting 255: 255/16 = 15 remainder 15. Since both quotient and remainder are 15, and 15 in hex is F, the result is FF. For 4660: 4660/16 = 291 remainder 4, 291/16 = 18 remainder 3, 18/16 = 1 remainder 2, 1/16 = 0 remainder 1. Reading bottom to top: 1234 in hex. Hexadecimal is popular in programming because each hex digit maps to exactly 4 binary bits, making it a compact way to write binary values.
What is the difference between signed and unsigned binary numbers?
Unsigned binary numbers represent only positive values and zero. An 8-bit unsigned number ranges from 0 (00000000) to 255 (11111111). Signed binary numbers use two's complement representation to include negative values. In 8-bit signed format, the leftmost bit indicates sign (0 for positive, 1 for negative), giving a range of -128 (10000000) to +127 (01111111). To negate a two's complement number, invert all bits and add 1. For example, +42 is 00101010; inverting gives 11010101, adding 1 gives 11010110, which represents -42. Most programming languages default to signed integers.
Where are binary, hex, and octal numbers used in real life?
Binary is used internally by all digital systems but is rarely written by humans due to its length. Hexadecimal is used extensively in web development (HTML/CSS colors like #FF5733), memory addresses in debugging, MAC addresses in networking, and cryptographic hashes (SHA-256 produces a 64-character hex string). Octal is used primarily in Unix/Linux file permissions (chmod 755 means rwxr-xr-x), which sets read, write, and execute flags using 3-bit groups. Decimal remains the standard for human-facing interfaces, financial calculations, and everyday mathematics.