Number System Converter
Convert integers between binary, octal, decimal and hexadecimal. For negative values, choose the bit width and check whether you need a minus sign or two’s complement.
Enter a value in any of the four fields to update the others. Choose an 8-, 16-, 32- or 64-bit signed representation, or use unsigned mode for nonnegative integers without a fixed bit width.
What can this number system converter do?
The converter provides:
- Live conversion: No “Calculate” button. Start typing into the HEX field and instantly see how BIN and DEC change.
- Signed integers: Choose a bit width before entering a negative decimal value. Binary, octal and hexadecimal show its two’s-complement bit pattern.
- Binary grouping: Display binary values in groups of four bits, such as
1110 1010 1101 1110, to make them easier to read. - BigInt support: Integer conversion avoids JavaScript Number’s precision limit. Unsigned mode has no fixed bit width, although very long input still depends on your browser’s resources.
Number System Guide: When to Use Which?
1. Decimal System (DEC - Decimal)
- Base: 10 (digits 0-9)
- Usage: Everyday life, finance, counting loops in code.
2. Binary System (BIN - Binary)
- Base: 2 (digits 0, 1)
- Usage: Machine code, logic gates, IP address masking.
- Tip: Each digit represents one bit. 8 bits form 1 byte.
3. Hexadecimal System (HEX - Hexadecimal)
- Base: 16 (digits 0-9, letters A-F)
- Usage: Compact representation of binary code. One HEX character represents exactly 4 bits (a nibble). Two characters (e.g.,
FF) represent an entire byte. - Examples:
- Web colors:
#FF5733(Red, Green, Blue). - MAC addresses:
00:1A:2B:3C:4D:5E. - Memory dumps.
- Web colors:
4. Octal System (OCT - Octal)
- Base: 8 (digits 0-7)
- Usage: Historically older computers, today mainly Linux permissions (chmod).
- Example: The
chmod 755command sets rwx-rx-rx (read, write, execute) permissions.
How to Correctly Work with Negative Numbers?
This is the most advanced feature of our converter. A signed integer needs a representation for negative values. This converter uses two’s complement in its fixed-width modes.
However, the result of converting a negative number depends on how many bits the variable has allocated. Therefore, in the top bar, you will find the Bit Depth switch.
Example: What does the number -5 look like?
Try it yourself in our converter:
-
Set the width to 8-bit.
- Enter into DEC:
-5. - HEX Result:
FB. - BIN Result:
1111 1011. - Explanation: 256 − 5 = 251 (which is FB).
- Enter into DEC:
-
Set the width to 16-bit.
- Enter into DEC:
-5. - HEX Result:
FFFB. - Explanation: Because we have more space, “ones” fill the rest of the space to the left.
- Enter into DEC:
-
Set the width to Unsigned Only.
- If you enter
-5, the field will turn red. This mode accepts only nonnegative integers. To encode −5 as a two’s-complement pattern, select a fixed bit width.
- If you enter
Choose the representation required by your data. In signed 8-bit mode, HEX
FFrepresents −1, while in Unsigned Only mode it represents 255. For programming exercises, match the width and signedness of the specified type.
Quick Conversion Table (Cheat Sheet)
These are unsigned values; in a fixed-width signed mode, a set top bit changes the decimal interpretation.
| Decimal (DEC) | Hexadecimal (HEX) | Binary (BIN) | Note |
|---|---|---|---|
| 0 | 00 | 0000 | Zero |
| 1 | 01 | 0001 | |
| 10 | 0A | 1010 | |
| 15 | 0F | 1111 | Maximum 4-bit value (Nibble) |
| 16 | 10 | 0001 0000 | |
| 127 | 7F | 0111 1111 | Maximum signed 8-bit value |
| 255 | FF | 1111 1111 | Max value for unsigned 8-bit (byte) |
| 65 535 | FFFF | … | Maximum unsigned 16-bit value |
Frequently Asked Questions (FAQ)
What does "Bit Depth" mean?
It selects the signed two’s-complement width used here. The decimal range is −2n−1 to 2n−1 − 1: for 8 bits, −128 to 127; for 16 bits, −32,768 to 32,767. Binary, octal and hexadecimal fields accept raw bit patterns that fit that width. Out-of-range values are marked invalid rather than silently truncated. BigInt provides integer arithmetic; it is not itself a fixed 64-bit type.Why is the number 255 written as FF in HEX?
The hexadecimal system has 16 digits (0-9 and A-F), where F has a value of 15. The hexadecimal number `FF` is calculated as **15 × 16 + 15 × 1 = 240 + 15 = 255**.How do I convert a HEX color to RGB?
A web color, e.g., `#E05412`, consists of three bytes: Red (E0), Green (54), Blue (12). Enter "E0" into our converter's HEX field -> you get 224. Enter "54" -> you get 84. Enter "12" -> you get 18. The result is `rgb(224, 84, 18)`.What do the prefixes 0x, 0b, or 0o mean?
To distinguish number systems, programmers use prefixes:- `0x` = Hexadecimal (e.g., 0xFF)
- `0b` = Binary (e.g., 0b101)
- `0o` = Octal (e.g., 0o755)
Why did my field turn red?
The input may contain an invalid digit, a negative value in unsigned mode, or a value outside the selected bit width. For example:- The letter "G" in HEX (only A-F are allowed).
- The digit "2" in BIN (only 0 and 1 are allowed).
- The digit "8" in OCT (only 0-7 are allowed).
To encode the letters in a message as UTF-8 bytes, use the text to binary converter.