What the Binary and Hex Calculator does
The Binary and Hex Calculator does arithmetic directly in binary (base 2), octal (base 8), decimal and hexadecimal (base 16). Add, subtract, multiply or divide two numbers, find the remainder, or apply the bitwise operations AND, OR and XOR and left and right shifts used in programming and electronics. The answer is shown in all four bases at once. It works with whole numbers of any length.
How to use it
- Choose the number base you are typing in.
- Enter the two numbers. Prefixes such as 0b and 0x are fine.
- Choose the operation and read the result in every base.
Example
In binary, 1011 + 110 = 10001, which is 11 + 6 = 17 in decimal. 1011 AND 110 = 10, because only the second bit is set in both. In hex, FF × 2 = 1FE.
Bitwise operations
AND gives 1 only where both numbers have a 1, which is used to mask out bits. OR gives 1 where either has a 1, used to set bits. XOR gives 1 where the bits differ, used to flip bits and in simple checksums. Shifting left by n places multiplies by 2ⁿ; shifting right divides by 2ⁿ and drops the remainder.
Questions people ask
Is anything I enter sent anywhere?
No. The calculator works entirely in your browser, so your numbers stay on your device.
How do I convert a single number between bases?
Type it and choose add with 0, or use the Number Base Converter, which also handles any base from 2 to 36.
How are negative numbers handled?
Results can be negative and are shown with a minus sign. AND, OR and XOR treat negative numbers in two’s complement, the way most programming languages do.
Why is hex used so much in computing?
Each hex digit stands for exactly four binary digits, so a byte is two hex digits. FF is 11111111, which is much easier to read and type.