Binary Calculator
Convert numbers between binary, decimal, octal and hexadecimal, and do bitwise AND, OR, XOR, NOT and shifts in 8, 16 or 32 bits.
Binary
1111 1111
Decimal
255
Hexadecimal
0xFF
Octal
377
Result (decimal)
255
Result (binary)
1111 1111
Result (hex)
0xFF
Binary, Decimal and Hex Conversion with Bitwise Operations
Computers store everything as bits. This calculator converts an unsigned integer between binary, octal, decimal and hexadecimal, shows the binary in groups of four bits, and applies bitwise operations within an 8, 16 or 32-bit width so results match what a program would give.
Place values
| Bit | 7 | 6 | 5 | 4 | 3 | 2 | 1 | 0 |
|---|---|---|---|---|---|---|---|---|
| Value | 128 | 64 | 32 | 16 | 8 | 4 | 2 | 1 |
Conversion methods
- Binary → decimal: add the place values of the 1 bits (1010 = 8 + 2 = 10).
- Decimal → binary: divide by 2 repeatedly; read remainders bottom to top.
- Binary ↔ hex: 4 bits = 1 hex digit (1111 = F, 1010 = A).
- Binary ↔ octal: 3 bits = 1 octal digit.
Bitwise operations
| Operation | Rule | Example (8-bit) |
|---|---|---|
| AND | 1 if both bits are 1 | 12 AND 10 = 8 |
| OR | 1 if either bit is 1 | 12 OR 10 = 14 |
| XOR | 1 if the bits differ | 12 XOR 10 = 6 |
| NOT | Flip every bit | NOT 5 = 250 |
| Left shift | Move bits left, fill with 0 (× 2ⁿ) | 5 << 2 = 20 |
| Right shift | Move bits right (÷ 2ⁿ) | 200 >> 3 = 25 |
Worked examples
1. 255 in decimal (the default). Binary 1111 1111, hex 0xFF, octal 377.
2. Binary 1010. 8 + 2 = 10 decimal, 0xA hex, 12 octal.
3. 2025 in 16 bits. 0000 0111 1110 1001 = 0x7E9, octal 3751.
4. Masking. 12 AND 10: 1100 AND 1010 = 1000 = 8. The same idea finds a network address: IP AND subnet mask.
Values are unsigned. Results that exceed the bit width are cut to that width, as in fixed-size integers.
Related tools
- Subnet masks and network addresses: IP Subnet Calculator.
- Logic expressions: Boolean Algebra Calculator. Floating-point representation: Floating Point Calculator.
- Error detection: CRC Calculator and Hamming Distance Calculator.
Frequently Asked Questions
How do I convert binary to decimal?
Multiply each bit by its place value (powers of 2 from the right: 1, 2, 4, 8, …) and add them. 1010 = 8 + 0 + 2 + 0 = 10.
How do I convert decimal to binary?
Divide by 2 repeatedly and write the remainders from last to first. 10 ÷ 2 = 5 r 0, 5 ÷ 2 = 2 r 1, 2 ÷ 2 = 1 r 0, 1 ÷ 2 = 0 r 1, so 10 = 1010.
How do I convert binary to hexadecimal?
Group the bits in fours from the right and convert each group to one hex digit (0 to 9, A to F). 1111 1111 = FF; 0111 1110 1001 = 7E9.
What is 255 in binary and hex?
255 = 1111 1111 in binary = 0xFF in hexadecimal = 377 in octal. It is the largest value that fits in 8 bits (one byte).
What does bitwise AND do?
Each result bit is 1 only if both bits are 1. 12 AND 10 = 1100 AND 1010 = 1000 = 8. It is used to mask bits, for example to find a network address.
What do OR and XOR do?
OR gives 1 if either bit is 1 (12 OR 10 = 14). XOR gives 1 if the bits differ (12 XOR 10 = 6). XOR is used in checksums, parity and simple encryption.
What does NOT do and why does bit width matter?
NOT flips every bit. In 8 bits NOT 5 (0000 0101) is 1111 1010 = 250; in 32 bits it is 4,294,967,290. The width decides how many leading zeros get flipped.
What are left and right shifts?
A left shift by n multiplies by 2ⁿ (5 << 2 = 20); a logical right shift by n divides by 2ⁿ and drops the remainder (200 >> 3 = 25). Bits shifted past the width are lost.
How do I enter hex or binary numbers?
Choose the base and type the digits; prefixes such as 0x or 0b and spaces are ignored. Hex digits A to F can be upper or lower case.
Does this handle negative numbers?
It works with unsigned integers from 0 to 4,294,967,295. Negative numbers in two's complement can be read from the NOT result plus one.
Related Calculators
IP Subnet Calculator
Calculate subnet mask, network address, broadcast address, and number of usable hosts from an IP address and CIDR prefix length.
Boolean Algebra Calculator
Evaluate Boolean logic gates (AND, OR, XOR, NAND, NOR) for up to 3 inputs. View truth table outputs and minterm expressions.
Floating Point Calculator
Convert a decimal number to its IEEE 754 floating point representation. View sign, exponent, and mantissa bits for single and double precision.
Hamming Distance Calculator
Calculate the Hamming distance between two binary values. Determine the number of differing bit positions and error detection capability.
CRC Calculator
Calculate Cyclic Redundancy Check (CRC) values using polynomial division. Enter data and generator polynomial to compute CRC checksum.
Encoding Calculator
Calculate string encoding sizes, byte representations, and storage requirements for different character encodings.
More in Computer Science · Engineering calculators · All calculators A–Z