πŸ”’

Number Base Converter

Convert numbers between binary, octal, decimal, hexadecimal, and other bases up to base-36.

Number Base Converter

Enter a number in any base β€” see its representation in all others instantly.

How to Convert Between Binary, Hexadecimal, and Decimal

You are debugging a C program and see a memory address 0x1A3F. What is that in decimal? Type 1A3F, select hexadecimal, and see that it equals 6719 in decimal, 1101000111111 in binary, and 15277 in octal. The copy button lets you paste the decimal value into your debugger or the binary value into a bitwise mask.

The converter handles 15 bases: binary (2), ternary (3), quaternary (4), quinary (5), senary (6), septenary (7), octal (8), nonary (9), decimal (10), undecimal (11), duodecimal (12), hexadecimal (16), vigesimal (20), base 32, and base 36. A student learning positional notation can type 42 and see binary 101010, octal 52, and hex 2A simultaneously, understanding that the value stays the same while the representation changes. A developer working with RGB colours sees that #FF5733 equals decimal 16734003.

When the wrong base causes real problems

Hex colour codes confuse beginners

A designer hands you the colour code FF5733. You need to extract the red, green, and blue components. In hex, FF = 255, 57 = 87, 33 = 51. The RGB value is (255, 87, 51). Without understanding that each pair of hex digits represents one colour channel, a beginner might try to treat FF5733 as a single decimal number (16,734,003), which is useless for colour manipulation. This converter shows all three colour components instantly.

Bitwise flags require binary thinking

A file permission value of 755 in octal means the owner has read-write-execute (7 = 111 binary), group has read-execute (5 = 101), and others have read-execute (5 = 101). Converting 755 to binary shows 111101101, which reveals each permission bit. If you treat 755 as decimal instead of octal, you get completely wrong permissions. The converter lets you verify octal-to-binary conversions quickly.

Network subnet masks need binary precision

A subnet mask of 255.255.255.0 in decimal equals 11111111.11111111.11111111.00000000 in binary. The number of 1-bits (24) determines the CIDR notation: /24. If you miscount the bits, you might use /23 or /25, which changes the network size from 256 addresses to 512 or 128. The converter shows the binary representation so you can count the 1-bits accurately.

How the Number Base Converter Handles Binary, Hex, and Decimal

Every number has the same value regardless of base. Decimal 255 is binary 11111111, hex FF, and octal 377. The converter uses two algorithms: a division-remainder method for decimal-to-target conversion, and a positional-weight method for parsing source-base input. Both run entirely in your browser using JavaScript integer arithmetic.

Division-remainder algorithm for decimal to any base

To convert decimal 42 to binary: divide 42 by 2, get quotient 21 and remainder 0. Divide 21 by 2, get quotient 10 and remainder 1. Continue until quotient is 0. Reading remainders from last to first: 101010. The same method works for hex: 42 divided by 16 is 2 remainder 10 (A in hex). So 42 decimal = 2A hex. For base 36: 42 divided by 36 is 1 remainder 6, so 42 decimal = 16 base-36.

The digit characters are mapped using a lookup string: 0-9 for values 0-9, A-Z for values 10-35. When the remainder is 10, the digit is A. When 35, the digit is Z. This lets the converter handle all 15 supported bases (2 through 36) with a single mapping table.

Positional-weight parsing for source base to decimal

To parse hex 1A3F to decimal: each digit is multiplied by 16 raised to its position power. F (15) x 16^0 = 15. 3 x 16^1 = 48. A (10) x 16^2 = 2560. 1 x 16^3 = 4096. Sum = 6719. JavaScript's parseInt() function performs this internally, but the converter validates each digit against the source base first. If you enter G in base 16, it rejects it because G is not a valid hex digit.

The converter supports the JavaScript safe integer range: up to 2^53 - 1 = 9,007,199,254,740,991 (about 9 quadrillion). Beyond this, IEEE 754 double-precision floats lose the ability to represent every consecutive integer, and conversion results become unreliable. The tool shows an error message rather than displaying wrong values. Negative numbers are handled by preserving the sign prefix through both algorithms.

Frequently Asked Questions

How do I convert decimal 255 to binary?

Divide by 2 repeatedly and collect remainders: 255/2 = 127 R1, 127/2 = 63 R1, 63/2 = 31 R1, 31/2 = 15 R1, 15/2 = 7 R1, 7/2 = 3 R1, 3/2 = 1 R1, 1/2 = 0 R1. Reading remainders from bottom to top: 11111111. That is 8 bits, which fits in one byte. In hex, 255 = FF (15x16 + 15 = 255).

Why does hex use letters A through F?

Hexadecimal (base 16) needs 16 unique digits. After 0-9, the remaining 6 values (10-15) are represented by A-F. A=10, B=11, C=12, D=13, E=14, F=15. This makes hex compact: one hex digit equals exactly 4 binary bits. So FF hex = 11111111 binary = 255 decimal. Hex is used everywhere in computing: memory addresses, colour codes, hash values.

What is the largest number this converter can handle?

The converter supports up to 9,007,199,254,740,991 (2^53 - 1), which is about 9 quadrillion. This is the JavaScript safe integer limit. Beyond this, IEEE 754 double-precision floats lose accuracy and the converter shows an error instead of wrong results. For most practical purposes, this limit is more than sufficient.

How do I read a binary subnet mask?

A subnet mask 255.255.255.0 in binary is 11111111.11111111.11111111.00000000. Count the 1-bits: 24 ones, so it is a /24 CIDR mask. This means the first 24 bits identify the network and the last 8 bits identify hosts. A /24 network has 256 addresses (2^8 = 256). If you miscount and use /23, you get 512 addresses, which may overlap with an adjacent network.

What is base 36 used for?

Base 36 uses digits 0-9 and letters A-Z (values 0-35). It is used for compact identifiers: short URLs, game codes, and session tokens. Base 36 is efficient because it uses only alphanumeric characters (no special symbols) and produces shorter strings than hex or decimal for the same value. For example, 1000000 decimal = LFLS base 36 (only 4 characters).

Can I convert negative numbers between bases?

Yes. The converter preserves the negative sign through all conversions. Negative 42 decimal = -101010 binary = -2A hex = -52 octal. The sign is handled separately from the magnitude: the converter takes the absolute value, converts it using the division-remainder algorithm, then prepends the minus sign to the result.

numbersconverterbinaryoctaldecimalhexadecimalbaseconversioncomputer science

More Tools You Might Like

πŸ“Length Converter
βš–οΈWeight & Mass Converter
πŸ§ͺVolume Converter
🌑️Temperature Converter
πŸ“Area Converter
⏲️Pressure Converter