Bitwise AND OR XOR Calculator
Enter two non-negative whole numbers to compute AND, OR and XOR.
Result
How it is calculated
Both fields take whole numbers from 0 up to 9,223,372,036,854,775,807 (263 − 1), typed in ordinary decimal. The tool compares the two numbers bit by bit: A & B keeps a 1 only where both numbers have a 1, A | B keeps a 1 where at least one has it, and A ^ B keeps a 1 where exactly one has it. Digit strings are read as exact integers, so large values keep every digit. The three results are printed in decimal with digit grouping, and the XOR is also printed as a binary string with no leading zeros (an XOR of 0 shows as 0). Negative numbers, decimals, binary or hex text and values above the limit give no result, so two's complement is not modelled.
Worked example
Take A = 202 and B = 153. In binary 202 is 11001010 and 153 is 10011001. AND keeps the positions that are 1 in both, giving 10001000, which is 136. OR keeps positions that are 1 in either, giving 11011011, which is 219. XOR keeps positions where they differ, giving 01010011, which is 83, shown as 1010011. Check: AND + XOR = 136 + 83 = 219, the OR value.
Common mistakes
- Typing the numbers in binary or hexadecimal. The fields take decimal only, so enter 202, not 11001010 or CA; text like 0xCA returns no result.
- Expecting a negative number to work through two's complement. Negative inputs are rejected, so convert them to their unsigned form yourself first.
- Confusing bitwise AND with the logical AND used on true and false. This works on every bit of the number, so 12 and 10 gives 8, not true.
- Reading the XOR binary string as a fixed width. It has no leading zeros, so 83 appears as 1010011 and not as an 8-bit value.
- Entering a number above 9,223,372,036,854,775,807. That is the signed 64-bit maximum, and anything larger shows no result.
About this calculator
Bitwise AND, OR and XOR compare two numbers one binary digit at a time. AND returns 1 only where both numbers have a 1 in that position, OR returns 1 where either number has a 1, and XOR (exclusive or) returns 1 only where exactly one of the two numbers has a 1 — meaning matching bits cancel out to 0. Applying an operation to every bit position at once is what makes these ‘bitwise’ rather than the plain logical AND/OR used on whole true/false values.
Programmers use bitwise AND to mask off specific bits — such as checking a subnet mask against an IP address, or testing whether a particular flag is set in a bitfield — bitwise OR to combine flags together, and XOR for tasks like toggling bits, swapping two values without a temporary variable, simple stream ciphers, and detecting differences between two binary values, since XOR-ing something with itself always produces zero.
Was this helpful?
You can pick up to 3 reactions.
Popular calculators
Loan Calculator
Monthly payment, total interest and full amortization schedule.
Percentage Calculator
Percent change, percent of, and ratio calculations.
Discount Calculator
Calculate final price, savings, and discount amount.
BMI Calculator
Body mass index from height and weight (metric or imperial).
Age Calculator
Compute your exact age in years, months and days from a birth date.
Compound Interest Calculator
Calculate the final amount and interest earned with compounding.
All Calculators
- Loan Calculator
- Profit Calculator
- Discount Calculator
- BMI Calculator
- Percentage Calculator
- Ideal Weight Calculator
- Age Calculator
- Pregnancy Due Date Calculator
- Compound Interest Calculator
- BMR Calculator (Basal Metabolic Rate)
- Tip Calculator
- Fuel Cost Calculator
- Date Difference Calculator
- Sleep Cycle Calculator
- Daily Water Intake Calculator
- Simple Interest Calculator
- Heart Rate Zones Calculator
- Running Pace Calculator
- Pet Age Calculator
- Calories Burned Calculator
- Macro Calculator
- TDEE Calculator (Total Daily Energy Expenditure)
- Waist-to-Hip Ratio Calculator
- Honor Roll Calculator
- One Rep Max (1RM) Calculator
- Ovulation Calculator
- Electricity Cost Calculator
- Unit Price Calculator
- Savings Goal Calculator
- Break-Even Point Calculator
- Paint Calculator
- Course Grade Average Calculator
- Business Days Calculator
- Time Duration Calculator
- Fuel Economy Calculator
- Temperature Converter
- Tile Calculator
- Aspect Ratio Calculator
- Roman Numeral Converter
- Goal Weight Timeline Calculator
- Salary Converter (Hourly to Annual)
- Credit Card Validator (Luhn)
- Body Surface Area (BSA) Calculator
- Feels-Like Temperature Calculator
- Ohm’s Law Calculator
- PPI (Pixel Density) Calculator
- Molar Mass Calculator
- Zodiac Sign Calculator (Western + Chinese)
- IBAN Validator
- Shoe Size Converter
- Country Info & Dialing Code Lookup
- Time Zone Difference (World Clock)
- CAGR (Compound Annual Growth Rate) Calculator
- Rule of 72 Calculator
- Blood Alcohol Content (BAC) Calculator
- Lean Body Mass (LBM) Calculator
- Pythagorean Theorem Calculator
- Speed Converter
- Download Time Calculator
- Date Calculator (Add/Subtract)
No calculators found
Comments