Binary Calculator
Convert between decimal and binary numbers, and perform bitwise operations (AND, OR, XOR) on two binary numbers.
Decimal ↔ Binary Conversion
Binary Operations
About this Calculator
Convert between decimal and binary numbers, and perform bitwise operations (AND, OR, XOR) on two binary numbers.
Formula & Calculations
Formula
Decimal to Binary: repeated division by 2. Binary to Decimal: sum of (digit × 2^position).Where:
- Binary=A base-2 numeral system using only digits 0 and 1
- Decimal=The standard base-10 numeral system
- AND, OR, XOR=Bitwise logical operations applied to each pair of corresponding bits
Assumptions
- Input decimal numbers must be non-negative integers.
- Binary inputs must contain only 0 and 1 characters.
- Bitwise operations are performed on the integer values of the binary inputs.
Calculation Examples
Example 1
Inputs:Decimal 42 → Binary
Result:101010
42 in binary: 32 + 8 + 2 = 101010.
Example 2
Inputs:AND: 1100 & 1010
Result:1000 (binary) = 8 (decimal)
Bitwise AND: 1&1=1, 1&0=0, 0&1=0, 0&0=0 → 1000.
Frequently Asked Questions
Why do computers use binary?
Binary uses only two states (0 and 1), which maps directly to electronic circuits being off (0) or on (1). This makes binary the natural language of digital computers, where transistors act as switches.
What are bitwise operations used for?
Bitwise operations are used in low-level programming for flags, masks, encryption, graphics, compression, and hardware control. AND masks bits, OR sets bits, and XOR toggles bits.