Toolstia / Bitwise calculator
Bitwise calculator
Enter two integers in decimal, hex or binary and apply a bitwise operation. The result is shown in decimal, hex and binary, both unsigned and as a signed two's complement value, for the word size you choose.
Numbers wrap around at the chosen width, as in a real register. Negative numbers use two's complement, so -1 is all ones. Arithmetic shift right keeps the sign bit, while the other shift right fills with zeros.
How it works
- Pick the number base and word size.
- Enter A and B, and choose the operation.
- Read the result in every format.
Operations
AND, OR, XOR, NOT, left shift, right shift that keeps the sign, and right shift that fills with zeros.
Word size
Results are cut to 8, 16, 32 or 64 bits, just like a register of that size. Big integers are used, so 64-bit values are exact.
Signed values
In two's complement the top bit is the sign. An 8-bit value of 255 is -1 when read as signed.
Input bases
Choose decimal, hexadecimal or binary. A leading 0x or 0b is accepted, underscores are ignored, and negative numbers are written with a minus sign.
Questions
Is 64-bit exact?
Yes. The tool uses arbitrary precision integers instead of floating point numbers. Everything happens in your browser, and nothing you enter is sent anywhere.
What is the difference between the right shifts?
Logical shifting fills with zeros. Arithmetic shifting copies the sign bit.
Why does NOT give a big number?
NOT flips every bit in the word, so for a positive number the unsigned result is large.