Encoding & Number Bases
Binary and Hex Calculator with Bit Widths
Calculate fixed-width binary and hex arithmetic with exact 64-bit integers, two's complement results, carry, overflow, and bit diagrams.
Worked example result
Select Load example to use these values in the calculator.
- A
- 0x7F
- Operation
- add
- Input base
- auto
- Bit width
- 8
- Interpretation
- signed
Result
- Hexadecimal
- 0x80
- Binary
- 1000 0000
- Octal
- 0o200
- Signed decimal
- -128
- Unsigned decimal
- 128
Flags
| Flag | Value | Meaning for this operation |
|---|---|---|
| CF | 0 | Unsigned carry beyond the width. |
| OF | 1 | Signed overflow; bitwise operations clear overflow. |
| ZF | 0 | Result is zero. |
| SF | 1 | Highest result bit is 1. |
| PF | 0 | Low 8 bits contain an even number of ones. |
Bits
| 7 | 6 | 5 | 4 | 3 | 2 | 1 | 0 | |
|---|---|---|---|---|---|---|---|---|
| A | 0 | 1 | 1 | 1 | 1 | 1 | 1 | 1 |
| B | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 1 |
| Result | 1 | 0 | 0 | 0 | 0 | 0 | 0 | 0 |
Binary column working
Carry : 01111111 A : 01111111 B : 00000001 Result: 10000000 Each carry or borrow sits under its source bit.
127 + 1 does not fit in signed 8 bits, so the signed result wraps to -128.
Embed this tool
Select the code and copy it. You can change the height to fit your page.
The calculator retains the selected width after each operation. Interpretation determines the signed or unsigned decimal reading.
The result includes base representations, bits, and operation flags. Addition and subtraction include column calculations.
- Check carry and signed overflow in a computer science arithmetic exercise.
Inspect an 8-bit arithmetic result
Input: 0x7F
Settings: Operation: add; B: 0x01; Bit width: 8; Interpretation: signed
Result: -128
The pattern is 0x80. OF=1, CF=0, SF=1, ZF=0, and PF=0.
Choose bit width, operation, and signed interpretation
- Enter A, choose Operation, and enter B or count when required.
- Select Input base, Bit width, and Interpretation.
- Select Calculate fixed-width result.
- Only integer operands are supported.
- The flags do not reproduce every processor rule.
- Multiplication leaves ZF, SF, and PF unavailable.