💻

Binary & Hex Converter

Convert between binary, decimal, hexadecimal, and octal number systems

Number Systems

Binary (Base 2): Uses digits 0, 1
Decimal (Base 10): Uses digits 0-9
Hexadecimal (Base 16): Uses 0-9, A-F
Octal (Base 8): Uses digits 0-7

Binary Converter: Decimal, Hex, Octal, and Binary

Table of Contents - Binary Converter


How to Use This Converter - Binary Converter

Select your Input System: Binary, Decimal, Hexadecimal, or Octal.

Enter your Value in the input field. Optional prefixes like 0b (binary), 0x (hex), or 0o (octal) are accepted.

For binary conversions, configure:

  • Signed or Unsigned interpretation
  • Bit width (8-bit, 16-bit, 32-bit, 64-bit)

Results appear instantly in all other number systems as you type. No button press required.


The Core Principle: Positional Notation

All number systems use positional notation—each digit's value depends on its position.

Base systems:

  • Binary (base-2): digits 0-1
  • Octal (base-8): digits 0-7
  • Decimal (base-10): digits 0-9
  • Hexadecimal (base-16): digits 0-9, A-F

Position values: Each position represents the base raised to a power, starting from 0 on the right.

Decimal 1234 = 1×10³ + 2×10² + 3×10¹ + 4×10⁰ Binary 1101 = 1×2³ + 1×2² + 0×2¹ + 1×2⁰ = 8 + 4 + 0 + 1 = 13

Hexadecimal digits: A=10, B=11, C=12, D=13, E=14, F=15

Hex 2F = 2×16¹ + 15×16⁰ = 32 + 15 = 47

Signed versus unsigned:

  • Unsigned: all bits represent magnitude (0 to 2^n - 1)
  • Signed (two's complement): leftmost bit indicates sign (negative if 1)

8-bit unsigned range: 0 to 255 8-bit signed range: -128 to 127


How to Convert Between Number Systems

Binary to Decimal: Multiply each bit by its position value and sum.

11010110 (binary) = 1×128 + 1×64 + 0×32 + 1×16 + 0×8 + 1×4 + 1×2 + 0×1 = 128 + 64 + 16 + 4 + 2 = 214 (decimal, unsigned)

Decimal to Binary: Repeatedly divide by 2, collecting remainders.

47 ÷ 2 = 23 remainder 1 23 ÷ 2 = 11 remainder 1 11 ÷ 2 = 5 remainder 1 5 ÷ 2 = 2 remainder 1 2 ÷ 2 = 1 remainder 0 1 ÷ 2 = 0 remainder 1

Read remainders bottom-up: 101111 (binary)

Binary to Hexadecimal: Group bits into fours (from right), convert each group.

11010110 → 1101 0110 → D 6 → D6 (hex)

Hexadecimal to Binary: Convert each hex digit to 4 bits.

A5 → A=1010, 5=0101 → 10100101 (binary)


Real-World Applications

Programming and debugging. Understanding binary and hex is essential for low-level programming, memory inspection, and debugging.

Network configuration. IP addresses, subnet masks, and MAC addresses use binary and hexadecimal notation.

Color codes. Web colors use hexadecimal (e.g., #FF5733 = RGB 255, 87, 51).

File analysis. Hex editors display file contents in hexadecimal for analysis and modification.

Digital electronics. Hardware designers work directly with binary signals and logic.

Computer science education. Understanding number bases is foundational to computing concepts.


Scenarios People Actually Run Into

The signed/unsigned confusion. Binary 10000000 is 128 unsigned but -128 signed (8-bit two's complement). The same bits mean different values depending on interpretation.

The hex color puzzle. #FFFFFF is white (255,255,255) because FF in hex equals 255 in decimal.

The subnet mask mystery. /24 subnet mask is 255.255.255.0, which is 11111111.11111111.11111111.00000000 in binary—24 ones followed by 8 zeros.

The permission codes. Unix permissions like 755 are octal: 7=rwx (111), 5=r-x (101).

The overflow problem. 8-bit unsigned 255 + 1 = 0 (wraps around). Understanding bit width prevents unexpected behavior.


Trade-Offs and Decisions People Underestimate

Bit width selection. 8-bit, 16-bit, 32-bit, and 64-bit representations have different ranges. Choose based on your application's requirements.

Signed versus unsigned. Unsigned doubles your positive range but eliminates negative numbers. Know which your system uses.

Hexadecimal readability. Hex is more compact than binary (4 bits per digit versus 1) but less intuitive than decimal. It's a middle ground for human readability of binary data.

Leading zeros significance. In some contexts, leading zeros matter (fixed-width representations). In others, they're just formatting.

Endianness. Byte order (big-endian versus little-endian) affects how multi-byte values are stored. This converter shows the logical value, not storage order.


Common Mistakes and How to Recover

Invalid characters for base. Binary only uses 0 and 1. Hex uses 0-9 and A-F. Entering invalid characters produces errors.

Forgetting signed/unsigned setting. The same binary can represent vastly different decimal values. Always check your interpretation mode.

Mixing up bases. Is "10" binary (2), octal (8), decimal (10), or hex (16)? Use prefixes (0b, 0o, 0x) to be explicit.

Truncation errors. Converting a large number to a smaller bit width loses information. Ensure your bit width accommodates your values.

Case sensitivity in hex. Most systems accept both uppercase (A-F) and lowercase (a-f) for hex digits, but be consistent.


Related Topics

Two's complement. The standard method for representing signed integers in binary. Negative numbers are represented by inverting bits and adding 1.

Bitwise operations. AND, OR, XOR, NOT, and shift operations that manipulate individual bits.

ASCII and Unicode. Character encoding systems that map numbers to characters.

Floating-point representation. IEEE 754 standard for representing decimal numbers in binary (not covered by this converter).

Endianness. Byte ordering in multi-byte values (big-endian versus little-endian).


How This Converter Works

Decimal to binary:

binary = ""
while decimal > 0:
  binary = (decimal % 2) + binary
  decimal = floor(decimal / 2)

Binary to decimal:

decimal = 0
for i, bit in enumerate(reversed(binary)):
  decimal += int(bit) × 2^i

Binary to hexadecimal:

// Pad to multiple of 4 bits
// Group into 4-bit chunks
// Convert each chunk to hex digit (0-F)

Signed interpretation (two's complement):

if signedMode and leftmostBit == 1:
  // Negative number
  value = -(2^bitWidth - unsignedValue)
else:
  value = unsignedValue

All conversions happen locally in your browser with instant updates.


FAQs

What's the difference between binary and hex converters?

This tool handles both. Binary is base-2; hex is base-16. They're related—each hex digit represents exactly 4 binary bits, making conversion straightforward.

Why do results change with signed/unsigned setting?

The same binary pattern represents different values. Unsigned interprets all bits as magnitude. Signed uses two's complement, where the leftmost bit indicates sign.

What does "Invalid Input" mean?

You entered characters not valid for the selected base. Binary only accepts 0 and 1; hex accepts 0-9 and A-F.

Can this convert floating-point numbers?

No. This converter handles integers only. Floating-point uses the IEEE 754 standard, which is more complex.

What are the prefixes 0b, 0x, and 0o?

Standard programming prefixes: 0b for binary, 0x for hexadecimal, 0o for octal. They clarify which base you're using.

How does it convert so quickly?

It uses efficient algorithms (division/modulus for decimal-to-binary, lookup tables for hex) executed instantly by your processor.

Why is hex commonly used in programming?

Hex is compact (one digit per 4 bits) while still being easily convertible to/from binary. It's more readable than long binary strings.

What bit width should I use?

Match your application: 8-bit for bytes, 16-bit for short integers, 32-bit for standard integers, 64-bit for large values.


Additional Notes

Understanding number bases is fundamental to computer science and digital electronics. Binary is how computers actually store and process data. Hexadecimal provides a human-readable shorthand for binary. Decimal is what humans naturally think in. This converter bridges all these representations seamlessly.

Practical Tips

When debugging, hex is often easier to read than binary for memory addresses and data values. For permissions and small values, octal remains common in Unix systems. Always be explicit about your number base when communicating with others—ambiguity causes errors.

Further Learning

Explore bitwise operations to understand how computers manipulate individual bits. Study two's complement to understand negative number representation. Learn about character encodings (ASCII, Unicode) to see how text becomes numbers. Understanding these fundamentals makes you a better programmer and problem solver.

Understanding the Context

Number system conversion isn't just academic—it's practical for anyone working with computers at a low level. Network administrators use it for IP addressing. Programmers use it for debugging and optimization. Security researchers use it for analyzing malware. Game developers use it for efficient data packing.

Common Scenarios and Solutions

When you see a hex color code like #3498DB, you can convert each pair to decimal (34=52, 98=152, DB=219) to understand the RGB values. When configuring network subnets, converting between CIDR notation and binary helps visualize address ranges. When permissions seem wrong, converting octal to binary reveals exactly which bits are set.

Building Mastery

Practice converting small numbers mentally between bases. Memorize the hex values 0-F in decimal and binary. Learn to recognize common patterns like FF=255, 80=128 (in hex). With practice, reading hex becomes almost as natural as reading decimal.

Expert Insights

Experienced developers often think directly in hex for certain tasks. They recognize patterns without conscious conversion. This fluency comes from repeated exposure and practice. The converter is a tool for learning and verification, building toward that intuitive understanding.

Applications Beyond the Basics

Beyond simple conversion, understanding number bases enables working with binary protocols, analyzing network packets, reverse engineering software, understanding compression algorithms, and debugging hardware interfaces. These skills open doors in cybersecurity, embedded systems, and low-level optimization.

Summary

This converter provides instant, accurate translation between binary, decimal, hexadecimal, and octal number systems. Understanding these bases and their relationships is essential for anyone working with computers at a fundamental level. Use this tool to learn, verify, and build your intuition for digital number representation.

The skills developed through working with number bases serve you across many computing contexts. Regular practice builds the intuition needed for quick mental conversions. Understanding binary is understanding how computers think at their most fundamental level.

Technical Considerations

All modern computers use binary internally because transistors have two states: on and off. Everything—numbers, text, images, sound—is ultimately binary. Hexadecimal exists as a convenience for humans, grouping binary into manageable chunks. Octal is less common now but persists in Unix file permissions.

Integration with Other Tools

This converter complements hex editors, debuggers, network analyzers, and programming environments. Use it to verify calculations, understand unfamiliar values, and build fluency. The instant feedback accelerates learning compared to manual calculation.

Continuous Improvement

Keep practicing conversions until common patterns become automatic. Learn the powers of 2 (1, 2, 4, 8, 16, 32, 64, 128, 256, 512, 1024). Recognize that each hex digit position represents a power of 16. Build mental shortcuts for frequent conversions.

Professional Applications

Network engineers convert between dotted decimal and binary for subnet calculations. Programmers use hex for memory addresses, color codes, and binary data inspection. Security analysts read hex dumps when analyzing malware or network traffic. Hardware engineers work directly with binary for digital logic design.

Number base conversion is a foundational skill that supports countless specialized applications in technology fields. Master the basics here and apply them everywhere.