Matemática

Convert Between Binary, Decimal, and Hexadecimal

Instantly convert between binary, decimal, and hexadecimal. Enter any number, pick your source and target base, get the result immediately. Includes a full reference table and step-by-step explanation.

🗓️ Updated June 2026 Reviewed by
Calculator Free · Private
Reviewed by: (editorial policy ) · Last reviewed:
Have a website? Embed this calculator for free Free — copy the code and paste it on your website Embed on your site
<iframe src="https://hacecuentas.com/embed/base-conversion-decimal-binary-hex" width="100%" height="560" style="border:1px solid #e2e8f0;border-radius:12px;max-width:720px" loading="lazy" title="Convert Between Binary, Decimal, and Hexadecimal"></iframe>
<p style="font-size:13px;text-align:center;margin:8px 0">Powered by <a href="https://hacecuentas.com" target="_blank" rel="noopener">Hacé Cuentas</a> — <a href="https://hacecuentas.com/base-conversion-decimal-binary-hex" target="_blank" rel="noopener">Convert Between Binary, Decimal, and Hexadecimal</a></p>
Preview →

Paste it on your site. Keep the credit link — thanks for sharing. More widgets →

Base conversion is a core skill in computer science, digital electronics, and programming. Binary (base 2) is the language processors use internally; hexadecimal (base 16) is how programmers read binary values compactly — each hex digit equals exactly 4 bits. This calculator converts between decimal, binary, and hexadecimal instantly using successive division (dec → other) or positional sum (other → dec).

When to use this calculator

  • Computer science homework: convert 1010 1100 binary to hexadecimal and decimal.
  • Subnet masks: convert 255.255.255.0 to binary (11111111.11111111.11111111.00000000 = /24).
  • Debugging in C or Python: the debugger shows 0x1F3A — what is the decimal value? (7994).
  • CSS colors: #FF00AA in decimal RGB → R=255, G=0, B=170.
  • Microcontroller registers: read bit flags from hex values directly.

Conversion Reference: Decimal, Binary (8-bit), and Hexadecimal

DecimalBinary (8-bit)Hexadecimal
00000 000000
10000 000101
90000 100109
100000 10100A
150000 11110F
160001 000010
420010 10102A
1270111 11117F
1281000 000080
2551111 1111FF
2560001 0000 0000100
10230011 1111 11113FF
655351111 1111 1111 1111FFFF

Fuente: Wolfram MathWorld — Base (Number); valores verificados mediante división sucesiva y suma posicional según metodología estándar de conversión de bases.

How it works

How Base Conversion Works

Decimal → Binary or Hex (successive division)


1. Divide the number by the target base (2 for binary, 16 for hex).
2. Record the remainder (0–1 for binary; 0–F for hex).
3. Repeat with the quotient until it reaches 0.
4. Read the remainders from bottom to top.

Example: 42 decimal → binary

  • 42 ÷ 2 = 21 r 0

  • 21 ÷ 2 = 10 r 1

  • 10 ÷ 2 = 5 r 0

  • 5 ÷ 2 = 2 r 1

  • 2 ÷ 2 = 1 r 0

  • 1 ÷ 2 = 0 r 1

  • Result: 101010
  • Binary or Hex → Decimal (positional sum)


    Each digit × base^position (position starts at 0 from the right).

    Example: 101010 binary → decimal

  • 1×2⁵ + 0×2⁴ + 1×2³ + 0×2² + 1×2¹ + 0×2⁰

  • 32 + 0 + 8 + 0 + 2 + 0 = 42
  • Binary ↔ Hex (shortcut)


    Group binary digits into sets of 4 from the right; each group = 1 hex digit.
  • 1010 1100 → 1010 (A) 1100 (C) → AC
  • Conversion Reference Table

    DecimalBinary (8 bits)Hex
    00000 000000
    10000 000101
    90000 100109
    100000 10100A
    150000 11110F
    160001 000010
    420010 10102A
    1270111 11117F
    1281000 000080
    2551111 1111FF
    2560001 0000 0000100
    10230011 1111 11113FF
    655351111 1111 1111 1111FFFF

    Real-World Applications

  • Subnet mask 255.255.255.0: each octet in binary = 11111111.11111111.11111111.00000000 — the 24 ones give us /24 CIDR notation.

  • CSS color #1E90FF (DodgerBlue): R=1E=30, G=90=144, B=FF=255 → rgb(30, 144, 255).

  • MAC address 00:1A:2B:3C:4D:5E: 6 hex pairs; total address space = 256⁶ ≈ 281 trillion.

  • ASCII 'A': decimal 65, binary 0100 0001, hex 41.

  • HTTPS port 443: hex 0x01BB = 443 decimal.
  • Common Mistakes

  • Treating hex letters as variables: in 0xFF, the F is the digit 15, not a variable. Always use the 0x prefix in code.

  • Missing leading zeros: in 8-bit formats, decimal 5 as a byte is 0000 0101, not 101.

  • Negative numbers: most systems use two's complement. −1 in 8 bits = 1111 1111, the same bit pattern as 255 unsigned.

  • Floating-point decimals: 0.1 has no exact binary representation (IEEE 754); expect small rounding errors.
  • Example: 255 decimal to hexadecimal

    Input: 255 | From: Decimal | To: Hexadecimal
    255 ÷ 16 = 15 remainder 15 (F)
    15 ÷ 16 = 0 remainder 15 (F)
    Read remainders bottom-up: FF
    FF

    Frequently asked questions

    Why is hexadecimal used in programming?
    Each hex digit represents exactly 4 bits (1 nibble), so one byte maps to just 2 hex digits (00 to FF). This makes memory addresses, color codes, CPU registers, and binary data far more readable than a long string of 0s and 1s.
    How do I convert binary to hexadecimal without a calculator?
    Group the binary digits into sets of 4 starting from the right. Convert each group to its hex equivalent. Example: 1010 1100 → A (1010) C (1100) → AC. If the total bits are not a multiple of 4, pad with leading zeros.
    What do 0x, 0b, and 0o prefixes mean in code?
    '0x' means hexadecimal (0xFF = 255). '0b' means binary (0b1010 = 10). '0o' or a leading zero in C means octal (0o77 = 63). These prefixes tell the compiler how to interpret the number literal.
    How are negative numbers represented in binary?
    The standard method is two's complement: flip all bits, then add 1. In 8 bits: +5 = 0000 0101, −5 = 1111 1011. Adding them gives 0000 0000 with the overflow bit discarded. This lets CPUs add and subtract using the same circuit.
    Why does one byte go from 0 to 255?
    A byte has 8 bits; each bit can be 0 or 1. Total combinations: 2⁸ = 256. Starting from 0, the maximum is 255. For 16 bits: 65,536 values (0–65,535). For 32 bits: 4,294,967,296 values (~4 billion).
    How do I read a CSS hex color in decimal RGB?
    Split the 6-character code into three pairs (RR GG BB) and convert each pair to decimal. Example: #FF6347 (Tomato) → FF=255, 63=99, 47=71 → rgb(255, 99, 71). Chrome DevTools shows all formats automatically when you click a color swatch.
    How much is hex A1 in decimal?
    A×16¹ + 1×16⁰ = 10×16 + 1 = 161 decimal. In binary: 1010 0001. Quick hex digit table: A=10, B=11, C=12, D=13, E=14, F=15.
    What is the difference between octal and hexadecimal?
    Octal (base 8) uses digits 0–7 and groups binary digits in sets of 3. Hex (base 16) uses 0–9 and A–F, grouping in sets of 4. Hex aligns perfectly with bytes (8 bits = 2 hex digits), making it far more common. Octal still appears in Unix file permissions (chmod 755).
    How are floating-point numbers stored in binary?
    Using the IEEE 754 standard: 1 sign bit + 8 exponent bits + 23 mantissa bits (single precision), or 64 bits total in double precision. The decimal 0.1 has no exact binary representation (it is a repeating fraction in base 2), which is why 0.1 + 0.2 equals 0.30000000000000004 in most programming languages.

    Methodology & trust

    Editorial

    Calculadora de matemática revisada por el equipo editorial de Hacé Cuentas, contrastada con IEEE 754-2019 — Standard for Floating-Point Arithmetic, según nuestra política editorial y metodología.

    Updates

    Última revisión: June 20, 2026. Los parámetros se verifican periódicamente con las fuentes citadas.

    Privacy

    Calculations run 100% in your browser. We do not store or transmit your data.

    Limitations

    Indicative results. For critical decisions, consult a professional.

    📌 How to cite this calculator

    Rodríguez, M. (2026). Convert Between Binary, Decimal, and Hexadecimal. Hacé Cuentas. https://hacecuentas.com/base-conversion-decimal-binary-hex

    Contenido bajo licencia CC-BY 4.0 — reutilizable citando la fuente con enlace a Hacé Cuentas.

    ✉️ Reportar un error en esta calculadora