Programmer Calculator
Do integer math in hex, decimal, octal or binary with bitwise operators and shifts. Results wrap like a real 8, 16, 32 or 64-bit register, signed or unsigned.
BitsClick a bit to flip it
Operators, from highest to lowest precedence
( )Grouping- ~Negate, bitwise NOT* / %Multiply, divide (rounds toward zero), remainder+ -Add, subtract<< >> >>>Shift left, arithmetic shift right, logical shift right&AND^XOR|OR0x 0o 0bHex, octal and binary prefixes work in any input mode. Use _ to group digits.Questions
What does "signed" change?
It only changes how the same bits are read in decimal. In 8 bits, 1111 1111 is 255 unsigned or -1 signed, using two's complement. Hex, octal and binary show the raw bits either way.
Why does 127 + 1 give -128?
That is overflow. In a signed 8-bit register the largest value is 127, so adding 1 wraps around to the smallest value, -128, just like in C, Java or Go.
What is the difference between >> and >>>?
>> keeps the sign bit, so negative numbers stay negative. >>> fills in zeros from the left and treats the value as unsigned.