Number System Converter: BIN/HEX/DEC/OCT with Negative Numbers

The world of computers runs on zeros and ones, but humans think in decimals. And programmers? They must understand everything in between. Whether you’re debugging low-level code, setting colors in CSS, calculating IP masks, or solving computer science problems, you encounter the need to convert numbers between systems.

Common calculators in Windows or on mobile are often slow and clunky. Our smart number system converter was designed by developers for developers. It offers instant real-time conversion, support for extremely large numbers, and as one of the few online tools, it correctly handles negative numbers in binary form.

What can this number system converter do?

When developing this widget, we focused on solving the most common pain points for programmers:

  1. Real-time Reactivity: No “Calculate” button. Start typing into the HEX field and instantly see how BIN and DEC change.
  2. Negative Number Support (Signed Integers): Most online converters fail when you type -5. We don’t. Thanks to the bit depth selection (8, 16, 32, 64 bits), we simulate precise processor behavior using the so-called two’s complement.
  3. Readable Binary Code: Staring at 1110101011011110 is a strain on the eyes. Our tool can automatically format the output into 4-bit groups (nibbles) like 1110 1010 1101 1110, which radically reduces errors when transcribing.
  4. BigInt Support: Need to convert a 64-bit number or a hash? Standard JavaScript stops at $2^{53}$. Our engine can handle arbitrarily long numbers in “Unsigned” mode.

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.
  • Interesting Fact: Computers don’t understand it directly; they must convert it to binary.

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.

4. Octal System (OCT - Octal)

  • Base: 8 (digits 0-7)
  • Usage: Historically older computers, today mainly Linux permissions (chmod).
  • Example: The chmod 755 command sets rwx-rx-rx (read, write, execute) permissions.

How to Correctly Work with Negative Numbers?

This is the most advanced feature of our converter. In computer memory, there is no “minus” sign. To store a negative number, computers most often use the two’s complement method.

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:

  1. Set the width to 8-bit.

    • Enter into DEC: -5.
    • HEX Result: FB.
    • BIN Result: 1111 1011.
    • Explanation: $256 - 5 = 251$ (which is FB).
  2. 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.
  3. Set the width to Unsigned Only.

    • If you enter -5, the field will turn red. This mode does not support negative numbers, as it would require infinitely many ones.

Pro Tip: If you are working with colors or IP addresses, always use the “Unsigned Only” mode. If you are doing assignments in C/C++ or assembly, switch to 32-bit or 64-bit.


Quick Conversion Table (Cheat Sheet)

For quick reference, here are basic values that every “techie” should know by heart.

Decimal (DEC)Hexadecimal (HEX)Binary (BIN)Note
0000000Zero
1010001
100A1010
150F1111Maximum 4-bit value (Nibble)
16100001 0000
1277F0111 1111Max value for signed 8-bit (char)
255FF1111 1111Max value for unsigned 8-bit (byte)
65 535FFFFMax value for 16-bit

Frequently Asked Questions (FAQ)

What does "Bit Depth" mean? It determines how much memory is allocated for a number.
  • **8-bit:** Values 0 to 255 (or -128 to 127). Corresponds to `char` or `byte` types.
  • **16-bit:** Values up to 65,535. Corresponds to the `short` type.
  • **32-bit:** Standard `int` in modern languages.
  • **64-bit:** For very large numbers (`long long`, `BigInt`).
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 number `FF` is calculated as: $(15 \times 16^1) + (15 \times 16^0) = 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)
Our converter recognizes these notations, but it is not necessary to type them.
Why did my field turn red? This is an input validation feature. It means you entered a character that does not belong to the given number system. 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).
Correct the typo, and the calculation will continue.