Skip to main content
Screendesk
Free tool

Number Base Converter

Convert between binary, octal, decimal, hexadecimal, and any base from 2 to 36. Exact for huge values, with negative numbers and two’s complement.

Open source on GitHub

Number

Whole numbers of any size. A leading minus sign, 0x / 0b / 0o prefixes, and spaces or underscores between digits are fine.

Result

Hexadecimal (base 16)

7 E8

Binary (base 2)

111 1110 1000

Octal (base 8)

3 750

Decimal (base 10)

2,024

11 bits · 4 decimal digits

Two’s complement

Fits in 32 bitsSigned range -2,147,483,648 to 2,147,483,647, unsigned 0 to 4,294,967,295

Bit pattern

0000 0000 0000 0000 0000 0111 1110 1000

Hex

0x00 00 07 E8

As signed integer

2,024

As unsigned integer

2,024

Runs entirely in your browser. Nothing you type here is uploaded or stored.

How it works

Converting 2024 to hex, step by step. Repeated division works for any target base.

Converting decimal 2024 to hexadecimal
StepCalculationResult
1. Divide by the target base2024 ÷ 16 = 126, remainder 8Lowest digit: 8
2. Divide the quotient again126 ÷ 16 = 7, remainder 14Next digit: E (14)
3. Repeat until the quotient is 07 ÷ 16 = 0, remainder 7Highest digit: 7
4. Read remainders bottom to top7, E, 82024 = 0x7E8
5. Check by expanding7 × 16² + 14 × 16 + 8 = 1792 + 224 + 82024 ✓
Reference

Counting from 0 to 16 in four bases. Each hex digit maps to exactly four binary digits.

0 to 16 in decimal, binary, octal, and hexadecimal
DecimalBinaryOctalHex
0000000
1000111
2001022
3001133
4010044
5010155
6011066
7011177
81000108
91001119
10101012A
11101113B
12110014C
13110115D
14111016E
15111117F
161 00002010
In code

How to write each base in code. Literal prefixes by language.

Number literal prefixes
BaseLiteralWhere it works
Binary (2)0b1010JavaScript, Python, Java 7+, C23, C++14, Rust, Go, Swift
Octal (8)0o12JavaScript, Python 3, Rust, Swift, Go 1.13+. C, Java, and older code use a bare leading 0 (012), a common source of bugs.
Hexadecimal (16)0xAAlmost every language. CSS colors use # (#0A0A0A); assembly listings often use a trailing h (0Ah).
Any baseparseInt("z", 36)JavaScript parseInt(text, radix) and Number.prototype.toString(radix) accept bases 2–36; Python has int(text, base).
FAQ

Frequently asked questions

How do I convert a number from one base to another?

Divide the number by the target base again and again, writing down each remainder, until the quotient reaches 0. The remainders read from last to first are the digits in the new base. To go the other way, multiply each digit by the base raised to its position and add the results. This converter does both instantly for any base from 2 to 36.

Why do bases stop at 36?

Base 36 uses all ten digits plus the 26 letters A–Z, so it is the largest base you can write with ordinary alphanumeric characters. It is used for short IDs and URL shorteners. Letters are case-insensitive here, so ff and FF are the same hex value.

Can it convert very large or negative numbers?

Yes. Values are stored as JavaScript BigInt, so a 40-digit decimal number converts without the rounding you get above 2^53 with regular numbers. Negative numbers keep their minus sign in every base, and the two’s complement panel shows how a computer stores them in 8, 16, 32, or 64 bits.

What is two’s complement?

Two’s complement is how computers store signed integers. A negative number −n is stored as 2^bits − n, so −1 in 8 bits is 11111111 (0xFF) and −128 is 10000000. The same bit pattern can be read as signed or unsigned, which is why the panel shows both. If a value needs more bits than the width you choose, it is flagged as an overflow.

Does it convert fractions?

No, this converter handles whole numbers only. Fractions such as 0.1 often have no exact representation in binary, so converting them means choosing a precision. Most bug-hunting uses of base conversion, such as error codes, flags, and IDs, are integers.

Customer support runs on Screendesk.

Start for free