💻 Coding

Base Converter

Convert a number between binary, octal, decimal, hexadecimal, or any custom base from 2 to 36, with every field editable and synced live.

Presets:


    

What is Number Base Conversion and How Does It Work?

Quick Answer: Number base conversion translates a numerical value from one positional numeral system (radix) to another, including binary (base 2), octal (base 8), decimal (base 10), and hexadecimal (base 16). Using Horner's polynomial evaluation method with arbitrary-precision BigInt arithmetic, the actual integer value remains constant while its symbolic representation adapts to different computational or hardware formats.

In modern computer science and digital electronics, positional numeral systems represent numerical quantities as polynomial sums of powers of a given radix (base). While human civilization standardized on decimal (base 10) due to ten anatomical fingers, electronic computing systems operate natively on binary (base 2) because microscopic transistor gates alternate reliably between two physical voltage thresholds: saturation (logic high, 1) and cutoff (logic low, 0). Consequently, intermediate radices such as octal (base 8) and hexadecimal (base 16) were introduced as compact, human-readable representations that map directly onto binary word boundaries without mathematical rounding. This Base Converter executes bi-directional, arbitrary-precision conversions across standard radices and arbitrary bases from 2 to 36 with real-time synchronization.

Mathematical Foundations: Radix Polynomial Expansion

In any positional numeral system with an integer radix \(b \ge 2\), an integer string \(D = d_{n-1} d_{n-2} \dots d_1 d_0\) represents an absolute numerical value \(V\) defined by the polynomial summation:

V = ∑_{i=0}^{n-1} d_i × b^i = d_{n-1} × b^{n-1} + d_{n-2} × b^{n-2} + &dots; + d_1 × b^1 + d_0 × b^0

Each coefficient \(d_i\) must be a valid digit in the range \(0 \le d_i < b\). In decimal, \(b = 10\) and the valid digits are 0 through 9. When the radix exceeds 10, alphabetical characters supply supplementary numerical symbols. Base 16 (hexadecimal) introduces the letters a through f (representing values 10 through 15). Extending this alphanumeric notation through all 26 Latin letters (a through z, where z denotes 35) establishes Base 36 as the theoretical ceiling for standard case-insensitive alphanumeric representation.

Conversion Algorithms: Horner's Method vs. Successive Euclidean Division

Translating numbers between two arbitrary radices \(b_1\) and \(b_2\) involves a dual-stage pipeline that normalizes the input into an internal numeric value before synthesizing the target output representation:

Why BigInt Precision is Essential for Low-Level Systems

Many elementary web calculators rely on standard JavaScript numbers. Under the ECMAScript specification, standard numbers adhere to IEEE-754 double-precision floating-point format (binary64). In this format, exactly 53 bits are allocated to the fractional significand, restricting exact integer representation to the interval \([-(2^{53} - 1), 2^{53} - 1]\) (specifically, \([-9,007,199,254,740,991, +9,007,199,254,740,991]\)).

When software engineers inspect 64-bit CPU memory pointers (e.g., 0x7ffeefbff568), 128-bit cryptographic nonces, IPv6 interface addresses, or raw binary bitmasks, standard floating-point functions like parseInt(hex, 16) silently truncate lower bits, producing catastrophic silent corruption without throwing errors. This Base Converter is architected entirely upon native ECMAScript BigInt primitives, enabling arbitrary-precision integer arithmetic across arbitrarily large bit vectors with zero precision loss.

Positional Numeral Systems Reference Table

Radix (Base) Standard Name Digits / Alphabet Bits per Digit Common Computing Applications
Base 2 Binary 0, 1 1 bit Logic gates, memory bits, bitmasks, CPU instructions
Base 8 Octal 0-7 3 bits Unix file permissions (chmod 755), legacy PDP architectures
Base 10 Decimal 0-9 ~3.32 bits Human everyday arithmetic, financial accounting, metrics
Base 16 Hexadecimal 0-9, a-f 4 bits (1 nibble) Memory addresses, CSS hex colors, byte inspections, SHA hashes
Base 32 Base32 (RFC 4648) A-Z, 2-7 5 bits Google Authenticator 2FA TOTP secrets, DNSSEC
Base 36 Alphanumeric 0-9, a-z ~5.17 bits URL shorteners, compact database primary keys, ticket IDs

Bit Layouts, Binary Nibbles, and Hardware Word Alignment

A nibble consists of exactly 4 binary bits, which corresponds directly to one hexadecimal character (\(2^4 = 16\)). Two consecutive hex characters represent exactly one 8-bit octet (byte). Grouping binary sequences into 4-bit nibbles provides crucial benefits during software debugging and firmware analysis:

Signed Numbers and Two's Complement Arithmetic

In pure mathematics, negative quantities are prefixed with an abstract minus sign (-). In physical silicon registers, however, negative numbers must be encoded using the same binary voltages used for positive values. Modern microprocessors implement Two's Complement representation:

For an \(n\)-bit integer, the most significant bit (MSB) acts as a negative sign weight of \(-2^{n-1}\), while all lower bits retain their standard positive weights. For example, in an 8-bit signed integer (int8):

Binary 0000 0001 = +1
Binary 0111 1111 = +127 (maximum positive int8)
Binary 1000 0000 = -128 (minimum negative int8)
Binary 1111 1111 = -128 + 64 + 32 + 16 + 8 + 4 + 2 + 1 = -1

This brilliant architectural innovation allows arithmetic logic units (ALUs) to perform both addition and subtraction using identical digital adder circuits without requiring specialized subtraction circuitry. When entering signed values into this converter, a leading minus sign is preserved and applied across all radices uniformly.

Practical Applications in Software and DevOps Engineering

Understanding and converting between number bases is fundamental across multiple IT disciplines:

  1. Unix File System Permissions (Chmod Octal): Linux file security partitions permissions into read (4), write (2), and execute (1) flags for user, group, and others. A permissions string like rwxr-xr-- corresponds directly to octal digits 7, 5, and 4 (chmod 754), where each octal digit packs 3 discrete permission bits.
  2. Color Systems in Web Development: CSS hexadecimal colors like #3b82f6 represent three consecutive 8-bit color channels: red (0x3b = 59), green (0x82 = 130), and blue (0xf6 = 246). Converting these values to decimal allows calculating perceptual luminance and WCAG contrast ratios.
  3. Networking and Subnetting: An IPv4 address like 192.168.1.1 is a four-byte sequence. When calculating CIDR subnets (such as /24 or /28), network engineers inspect the binary representation to determine where the host identifier separates from the network prefix.
  4. Base 36 Database Identifiers: High-throughput web applications frequently convert auto-incrementing 64-bit database IDs into Base 36 strings. For example, decimal integer 1234567890 compresses into compact alphanumeric slug kf12oi, producing concise, user-friendly URLs and support ticket tokens.

Zero-Server Client-Side Security Guarantee

All radix calculations, BigInt evaluations, and string transformations execute 100% within your client web browser via JavaScript. No cryptographic keys, memory addresses, database integers, or network packets are ever uploaded to remote servers. The tool functions completely offline with zero latency and absolute privacy.

Frequently Asked Questions

Why does this converter use BigInt instead of standard JavaScript numbers?

Regular JavaScript IEEE-754 numbers lose precision beyond 2^53 - 1 (9,007,199,254,740,991), silently rounding large values without warning. BigInt supports arbitrary-precision integers with zero roundoff errors, making it safe for 64-bit and 128-bit memory addresses, cryptographic integers, and large binary masks.

What algorithm converts arbitrary digit strings into numerical values?

This tool uses Horner's polynomial evaluation method. Moving left to right across the string, it multiplies the accumulator by the radix and adds the current digit value. Each digit is validated against the active base before multiplication.

Why is 36 the maximum base supported by standard alphanumeric systems?

Base 36 exhausts the 10 Arabic digits (0-9) and all 26 Latin letters (a-z) as single-character symbols. Radices above 36 require case sensitivity (like Base62) or special punctuation symbols (like Base64 and Base85).

How do hexadecimal numbers map directly onto binary bytes?

Because 16 equals 2 raised to the 4th power, each hexadecimal character represents exactly 4 binary bits (one nibble). Consequently, two hex characters represent exactly one 8-bit byte, providing clean visual bit-alignment.

How does this tool handle signed and negative integers across bases?

A leading positive (+) or negative (-) sign is recognized and stripped during digit parsing, then reapplied to the computed BigInt value across binary, octal, decimal, hex, and custom base representations.

Can I convert numbers between custom radices like base 7 or base 23?

Yes. The custom base controls allow specifying any radix from base 2 to base 36. Any value entered into the custom field automatically recalculates all standard and custom representations in real time.

How does repeated division convert decimal numbers into other bases?

To convert an integer to a target base, the integer is divided repeatedly by the target radix. The remainders recorded in reverse order from bottom to top form the target base digits until the quotient reaches zero.

What is the difference between unsigned and two's complement signed binary?

Unsigned binary treats all bits as positive magnitude values. Two's complement reserves the most significant bit as a negative weight (-2^(n-1)), allowing processors to perform subtraction using identical addition adder hardware.

Why do network addresses and subnet masks use hexadecimal and binary?

IPv4 and IPv6 subnetting operates on bit boundaries. Binary reveals network and host prefix splits directly, while hexadecimal compresses 128-bit IPv6 addresses into readable 16-bit colon-separated quartets.

Can this converter handle floating-point fractional numbers?

This tool focuses on arbitrary-precision integers to ensure zero mathematical rounding drift. Fractional floats in non-decimal bases introduce repeating rational expansions that cannot be represented losslessly without fixed-point limits.