Number Base Converter

🔢 What is Base Conversion?

Base conversion is the process of translating numbers from one numeral system (base) to another. Each base uses a different set of digits and follows specific place value rules. Understanding base conversion is fundamental in computer science, mathematics, and digital electronics.

Common Number Bases:

  • Binary (Base 2): Uses digits 0-1. Foundation of all digital systems.
  • Octal (Base 8): Uses digits 0-7. Common in Unix file permissions.
  • Decimal (Base 10): Uses digits 0-9. Our everyday number system.
  • Hexadecimal (Base 16): Uses 0-9, A-F. Essential for programming and memory addresses.

The same value in different bases:

  • Decimal: 42
  • Binary: 101010 (1×32 + 0×16 + 1×8 + 0×4 + 1×2 + 0×1)
  • Octal: 52 (5×8¹ + 2×8⁰)
  • Hexadecimal: 2A (2×16¹ + 10×16⁰)

⚙️ How This Number Base Converter Works

Our converter supports both integer and floating-point conversions with advanced features for professional and educational use.

🔥 Advanced Features:

  • Dual Mode Operation: Switch between integer and floating-point conversion modes.
  • Flexible Input Formats: Supports 0x, 0b, 0o prefixes and escape sequences (\x) for convenient input.
  • Complete Base Support: Convert between any base from 2 to 36, including uncommon bases.
  • Floating-Point Precision: Configurable decimal precision (3-12 digits) with repeating decimal detection.
  • Real-time Validation: Instant error detection with detailed feedback on invalid characters.
  • Dynamic Base Addition: Add/remove custom bases (Base 3, 5, 7, etc.) as needed.
  • Negative Number Support: Full support for negative values in all bases.
  • Visual Error Feedback: Color-coded input validation with specific error messages.

📊 Supported Input Formats:

Binary formats:

  • 0b101010 (standard prefix)
  • b101010 (short prefix)
  • 101010 (plain format)
  • 101010.101 (floating-point in Float Mode)

Hexadecimal formats:

  • 0x2A (programming style)
  • x2A (short prefix)
  • \x2A (escape sequence)
  • 2A.A (floating-point in Float Mode)

Octal formats:

  • 0o52 (modern prefix)
  • o52 (short prefix)
  • 052 (traditional C-style)
  • \052 (escape sequence)
  • 52.4 (floating-point in Float Mode)

📚 Step-by-Step Conversion Tutorial

🔄 Example 1: Decimal to Binary Conversion

Goal: Convert decimal 42 to binary using division method

Mathematical Process:

Step-by-step division by 2:

42 ÷ 2 = 21 remainder 0  ←
21 ÷ 2 = 10 remainder 1  ←
10 ÷ 2 = 5  remainder 0  ←
5  ÷ 2 = 2  remainder 1  ←
2  ÷ 2 = 1  remainder 0  ←
1  ÷ 2 = 0  remainder 1  ← (stop when quotient = 0)

Read remainders upward: 101010

Verification (Binary to Decimal):

Place value calculation:

Position: 5  4  3  2  1  0
Binary:   1  0  1  0  1  0
Values:   32 16 8  4  2  1

1×32 + 0×16 + 1×8 + 0×4 + 1×2 + 0×1 = 42 ✓

🔄 Example 2: Hexadecimal to Decimal Conversion

Goal: Convert hexadecimal 2A to decimal

Step-by-step breakdown:

Hex: 2A
Position values in base 16: 16¹, 16⁰

2A = 2×16¹ + A×16⁰
= 2×16 + 10×1    (A = 10 in decimal)
= 32 + 10
= 42

🔄 Example 3: Floating-Point Conversion

Goal: Convert decimal 42.625 to binary

Integer Part (42):

Same as Example 1: 42₁₀ = 101010₂

Fractional Part (0.625):

Multiplication method:

0.625 × 2 = 1.25  → integer part: 1, continue with 0.25
0.25  × 2 = 0.5   → integer part: 0, continue with 0.5
0.5   × 2 = 1.0   → integer part: 1, continue with 0.0 (stop)

Read integer parts downward: .101

Combined Result:

42.625₁₀ = 101010.101₂

Verification: 32+8+2 + 0.5+0.125 = 42.625 ✓

🔄 Example 4: Working with Uncommon Bases

Goal: Convert decimal 100 to base 7

Division by 7 method:

100 ÷ 7 = 14 remainder 2  ←
14  ÷ 7 = 2  remainder 0  ←
2   ÷ 7 = 0  remainder 2  ←

Read remainders upward: 202₇

Verification: 2×7² + 0×7¹ + 2×7⁰ = 98+0+2 = 100 ✓

💼 Professional Use Cases & Applications

1. Software Development & Programming

  • Memory Address Calculation: Convert between hex addresses and decimal offsets for debugging.
  • Bitwise Operations: Understand AND, OR, XOR operations by visualizing binary representations.
  • File Permissions: Convert Unix file permissions between octal (755) and binary representations.
  • Assembly Programming: Work with hex opcodes and binary instruction formats.
  • Network Programming: Convert IP addresses, port numbers, and protocol identifiers between different formats.
  • Data Analysis: Process numerical data in different bases for statistical analysis and visualization.
  • Embedded Systems: Convert between binary, octal, and hexadecimal for microcontroller programming.
  • Game Development: Handle game states, coordinates, and resource management using different number systems.
  • Database Operations: Convert primary keys, hash values, and encoded data between formats.
  • Mathematics & Research: Explore number theory, algorithmic efficiency, and computational mathematics.

Real Example - File Permissions:

  • Unix Permissions: 755
  • Owner: 7₈ = 111₂ (rwx)
  • Group: 5₈ = 101₂ (r-x)
  • Others: 5₈ = 101₂ (r-x)

2. Computer Science Education

  • Algorithm Visualization: Demonstrate how computers process different number systems.
  • Data Structure Analysis: Understand hash table indexing and array addressing.
  • Computer Architecture: Learn CPU instruction encoding and memory organization.
  • Floating-Point Understanding: Explore IEEE 754 representation and precision issues.
  • Cryptography Basics: Work with large numbers in different bases for encryption algorithms.

3. Digital Electronics & Hardware

  • Logic Circuit Design: Convert truth tables between binary and decimal representations.
  • Microcontroller Programming: Configure registers using hex values and understand binary flags.
  • Protocol Analysis: Decode communication protocols (SPI, I2C, UART) data frames.
  • Memory Layout: Calculate memory addresses and data structure offsets.
  • Embedded Systems: Work with ADC readings, PWM values, and sensor data.

4. Cybersecurity & Forensics

  • Malware Analysis: Analyze hex dumps and understand shellcode patterns.
  • Network Security: Convert packet data between hex and ASCII for analysis.
  • Reverse Engineering: Decode binary file formats and understand data structures.
  • Memory Forensics: Analyze memory dumps and locate specific patterns.
  • Cryptanalysis: Work with different number representations in encryption research.

5. Mathematics & Research

  • Number Theory: Explore patterns and properties in different base systems.
  • Statistical Analysis: Convert between number systems for data representation.
  • Scientific Computing: Handle precision and rounding in different number bases.
  • Game Development: Optimize graphics calculations and understand color blending.
  • Financial Technology: Process transaction IDs and implement checksums.

🔬 Advanced Mathematical Concepts

📐 Why Different Bases Matter

Each base has unique advantages for specific applications:

Base efficiency for different ranges:

  • Binary (Base 2): Perfect for digital logic (on/off states)
  • Octal (Base 8): Compact representation of 3-bit groups
  • Decimal (Base 10): Human-friendly, matches our finger counting
  • Hexadecimal (Base 16): Compact representation of 4-bit groups
  • Base 64: Efficient for encoding binary data as text

⚡ Floating-Point Precision Insights

Understanding precision limits:

Decimal: 0.1
Binary:  0.000110011001100... (repeating)
↑ Cannot be exactly represented in binary!

This is why: 0.1 + 0.2 ≠ 0.3 in programming

🔄 Conversion Algorithm Complexity

Understanding computational efficiency:

  • Time Complexity: O(log n) for converting n-digit numbers
  • Space Complexity: O(log n) for storing the result
  • Optimization: Powers of 2 bases can be converted via bit shifting

❓ Frequently Asked Questions

Q: What bases are supported?

A: You can convert between any base from 2 to 36, including decimal, binary, octal, and hexadecimal.

Q: Can I enter negative numbers?

A: Yes, negative numbers are supported in all bases.

Q: Is my data safe?

A: All conversions happen locally in your browser. No data is sent to any server.

Q: Can I copy the results?

A: Yes, click any output field to copy the value with a notification.

Q: Can I convert to uncommon bases (e.g., base 7, base 13)?

A: Yes, use the 'All Bases' section to convert to and from any base between 2 and 36.

🎯 Best Practices

  • Validate Input:Always check your input for valid digits in the selected base.
  • Error Handling:Handle invalid input gracefully in your applications.
  • Performance:For large numbers, use efficient algorithms for conversion.
  • Documentation:Document which bases are used and why in your codebase.
  • Testing:Test with edge cases, such as negative numbers and large values.
  • Security Awareness:Never trust unvalidated input from untrusted sources.

🔗 Related Tools

  • 3D Rotation Converter - Convert between Quaternions, Euler Angles, and 3×3 Rotation Matrices bidirectionally with interactive 3D visualization
  • Unit Converter - Convert between length, weight, temperature, pressure, speed, area, volume, data size, time, and energy units

Conversion Mode

Integer mode only. Enable Float Mode to work with decimal numbers.

Add Custom Base

Add bases 2-36 for specialized conversions
Common Bases
Integer Mode
Valid: 0-9 | Supports negative numbers
Valid: 0-1 | Formats: 0b, b, or plain
Valid: 0-7 | Formats: 0o, o, 0prefix, \, or plain
Valid: 0-9, A-F | Formats: 0x, x, \x, or plain