Binary Calculator
Numbers Written Four Different Ways
A computer only ever stores 1s and 0s, but humans rarely want to read a 32-digit binary string. Octal and hexadecimal exist as compact shorthand for exactly that binary data — hex in particular groups bits into clean 4-bit chunks, which is why you see it in color codes, memory addresses, and MAC addresses. This calculator converts a value between binary, octal, decimal, and hex, and separately performs binary arithmetic and bitwise logic on two binary numbers.
The Formula
Base conversion re-interprets the digit string using the target radix, then re-renders the resulting integer in each target base:
binary = bin(decimal_value)
octal = oct(decimal_value)
hex = hex(decimal_value)
For the arithmetic mode, both operands are first read as base-2 integers, the requested operation (add, subtract, multiply, integer divide, AND, OR, XOR) is applied to their decimal values, and the result is converted back to binary.
Where Base Conversion Matters
- Networking — subnet masks and IP addresses are frequently reasoned about in binary, then written in decimal for readability.
- Low-level programming — hex is the standard way to display memory addresses, color values (
#FF5733), and byte-level data, because two hex digits map exactly to one byte. - Digital logic — AND, OR, and XOR are the building blocks of circuit design, permission flags, and encryption routines, and are easiest to reason about bit by bit.
- File permissions — Unix-style permissions like
rwxr-xr-xare commonly expressed and typed as an octal number such as755.
Base Reference Table (0–15)
| Decimal | Binary | Octal | Hex |
|---|---|---|---|
| 0 | 0000 | 0 | 0 |
| 1 | 0001 | 1 | 1 |
| 2 | 0010 | 2 | 2 |
| 7 | 0111 | 7 | 7 |
| 8 | 1000 | 10 | 8 |
| 10 | 1010 | 12 | A |
| 12 | 1100 | 14 | C |
| 15 | 1111 | 17 | F |
Every 4-bit binary group maps to exactly one hex digit — this is why hex is used as compact shorthand for binary data.
How to Use This Calculator
- Choose a calculation type: Convert Number Base or Binary Arithmetic / Logic.
- For conversion, enter the Value and select the base it's currently written in (Binary, Octal, Decimal, or Hexadecimal); the result shows all four representations.
- For arithmetic, enter Binary Value A and Binary Value B, then choose an operation — Add, Subtract, Multiply, Divide, AND, OR, or XOR.
- Select Calculate to see the result in binary along with the decimal working.
Related Calculations
Working with network addresses instead of raw numbers? Try the IP Subnet Calculator. For file and data sizes, see the Storage Calculator.