Binary Calculator

Convert between binary, decimal, hexadecimal, and octal. Perform binary arithmetic including AND, OR, XOR.

Number Base Converter

Decimal

42

Binary

101010

Hexadecimal

2A

Octal

52

Binary Arithmetic

Result (Binary)

10

Result (Decimal)

2

How to Use the Binary Calculator

This calculator has two tools: a base converter and a binary arithmetic calculator.

Base Converter: Click the tab for the base you are starting from (Decimal, Binary, Hex, or Octal), type your number, and all other representations appear instantly.

Binary Arithmetic: Enter two binary numbers (using only 0s and 1s), select an operation, and see the result in both binary and decimal. NOT, Left Shift, and Right Shift only use the first number.

Binary Arithmetic Rules

AND:   1 AND 1 = 1, anything AND 0 = 0
OR:    0 OR 0 = 0, anything OR 1 = 1
XOR:   same bits = 0, different bits = 1
NOT:   flips all bits (0→1, 1→0)
Left Shift:  multiply by 2 (append 0 on right)
Right Shift: integer divide by 2 (remove last bit)

Example: 1010 (10) AND 0110 (6)
  1010
& 0110
------
  0010  = 2 decimal

Binary addition:
  0 + 0 = 0
  0 + 1 = 1
  1 + 1 = 10 (carry the 1)
  1 + 1 + 1 = 11

Frequently Asked Questions

Divide the number by 2 repeatedly, noting the remainder each time, until the quotient is 0. Read the remainders from bottom to top. For 42: 42÷2=21 r0, 21÷2=10 r1, 10÷2=5 r0, 5÷2=2 r1, 2÷2=1 r0, 1÷2=0 r1. Read remainders upward: 101010. So 42 in decimal = 101010 in binary.

Related Calculators