§ VI · Programmer
Base and Bitwise Calculator
Binary, octal, decimal and hex in one view, with two’s complement.
- Updated 2026-11-25
- Free · no sign-up
- Runs in your browser
1111 1111
Keys write in the base you select; the others go dead. You can also type a value directly: 0x for hex, 0b for binary, 0o for octal, and a leading minus sign is allowed. Changing the base rewrites the number you already have — 0xFF becomes 255 in dec — rather than starting over.
| Decimal | 255 |
|---|---|
| Binary | 1111 1111 |
| Octal | 377 |
| Hexadecimal | FF |
| Bits needed | 8-bit |
Two’s complement
8-bit 1111 1111
16-bit 0000 0000 1111 1111
32-bit 0000 0000 0000 0000 0000 0000 1111 1111
A negative value is stored as the complement of its magnitude plus one, which is why −5 shows as 1111 1011 at 8 bits.
Bitwise on two values
a AND b
2
binary 10 · hex 2
Try one
Compared with a basic calculator
| Task | Basic calculator | This page |
|---|---|---|
| Numbers | Decimal arithmetic | Binary, octal, decimal and hexadecimal |
| Operations | Basic arithmetic | Integer conversion and bitwise operations |
| Interpretation | Usually implicit | Selected width and signed representation are visible |
How to use it
§ How to use- 01
Type the number as 255, 0xFF, 0b1010 or -5. A leading minus sign is allowed.
- 02
Read the four bases and the bit width the value needs.
- 03
For a negative number, use the two’s complement block: the same value reads differently at 8, 16 and 32 bits.
- 04
For bitwise work, put two operands in and choose AND, OR, XOR, SHL or SHR.
What a decimal calculator loses
§ 02The same value, three ways of writing it.
| Question | Decimal only | ShowSteps |
|---|---|---|
| 255 in hex | FF | FF |
| −5 in 8 bits | -5 (sign and magnitude) | 1111 1011 |
| 0b1010 AND 0b0110 | 10 (binary lost) | 0b0010 = 2 |
Reading a number in another base
§ 03A base is just a choice of how many digits exist before a new column starts. Base 2 has two digits, base 16 has sixteen, and the value of a digit is its own value multiplied by the base raised to the position — counting from zero on the right.
0b1010 = 1·2³ + 0·2² + 1·2¹ + 0·2⁰ = 10
Hexadecimal is popular because one hex digit is exactly four binary digits, so a byte is always two characters. That is the whole reason 0xFF is easier to read than 1111 1111, and why memory addresses are printed in hex.
Why two’s complement is not “minus sign plus bits”
Sign-and-magnitude wastes a code (there would be both +0 and −0) and makes addition awkward. Two’s complement avoids both: negation is invert-and-add-one, and ordinary binary addition then works for negative numbers without a special case. The panel prints the padded bit pattern so the claim can be checked by hand.
Questions
§ 03- How do I enter hexadecimal or binary?
- Prefix the digits: 0xFF is hexadecimal, 0b1010 is binary, 0o17 is octal. Plain digits are read as decimal. Negative numbers are written with a leading minus sign.
- What is two’s complement?
- The way computers store negative integers. To represent −5 in eight bits you write 5 as 0000 0101, invert every bit to 1111 1010, and add one, giving 1111 1011. The panel shows the 8, 16 and 32-bit forms side by side.
- Why does the 8-bit value differ from the 32-bit value?
- Because the same number is padded to a different width. −5 is 1111 1011 at 8 bits and 1111 1111 1111 1111 1111 1111 1111 1011 at 32 bits; both are the same value, with different numbers of leading ones.
- How do shifts behave?
- SHL moves bits left, which multiplies by a power of two; SHR moves them right, which divides and discards the remainder. The second operand is the number of places, so 1 SHL 4 is 16.
- Is there a fixed bit width?
- Only in the two’s complement panel, which deliberately shows three widths. The arithmetic itself is unbounded, so large integers do not overflow here — which is a difference from a real 32-bit machine, and worth knowing.
- Why is XOR useful?
- It is its own inverse: a XOR b XOR b returns a. That is why it appears in toggling bits, simple checksums and encryption exercises.
- Which bases can it read and write?
- Binary, octal, decimal and hexadecimal are printed side by side, and the input accepts 0b, 0o and 0x prefixes. Values are not held to 64 bits, so a long hexadecimal string converts without overflowing.
- Can it handle a decimal point or a fraction?
- No, and it says so rather than truncating. A value like 0.1 has no exact binary form — it is a repeating fraction in base 2 — so this panel works on whole numbers only.
Related calculators
allArithmetic
Scientific Calculator
A full keypad that keeps surds exact and records every operation.
√8 + 3/8 + 5/12
Linear algebra
Matrix Calculator
Determinant, inverse and row reduction in exact fractions.
[2 1; 5 3]
Measurement
Unit Converter
One exact factor per conversion, and it tells you which factor.
32 psi → kPa
Arithmetic
Combinations & Permutations Calculator
Choose or arrange, in exact integers, repeats included.
C(10, 3) = 120
Arithmetic
Prime Factorisation Calculator
Any number up to 10¹², broken into primes, with the divisions shown.
360 = 2³ · 3² · 5
Arithmetic
fx-991 Style Calculator
A classic scientific keypad with editable expressions, Ans and replayable working.
√8 + 3/8 + 5/12