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.

Built by Sabki SolutionsRules: Unsigned integers up to 32 bitsLast updated

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

Bit76543210
Value1286432168421

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

OperationRuleExample (8-bit)
AND1 if both bits are 112 AND 10 = 8
OR1 if either bit is 112 OR 10 = 14
XOR1 if the bits differ12 XOR 10 = 6
NOTFlip every bitNOT 5 = 250
Left shiftMove bits left, fill with 0 (× 2ⁿ)5 << 2 = 20
Right shiftMove 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

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

More in Computer Science · Engineering calculators · All calculators A–Z