DevToolCase
Sign in Sign in

Convert binary, decimal and hexadecimal

Convert numbers between binary, octal, decimal, hexadecimal and any base up to 36, of any size, with two’s complement for negative numbers.

Share this result

Encrypted in your browser. The key stays in the link, after “#”: only the people you give it to can read it, not even DevToolCase.

The link works for

Sign in for longer links or links without expiry, and to find them in your account.

Type a number in any field, the others follow. Prefixes 0b, 0o and 0x, spaces, underscores and a minus sign are accepted.

Runs entirely in your browser: nothing you type is sent or stored.

How positional bases work

In base 10, each digit is worth ten times the one on its right: 255 is 2 × 100 + 5 × 10 + 5. Any base works the same way with its own multiplier: in base 2, 1101 is 8 + 4 + 0 + 1 = 13; in base 16, FF is 15 × 16 + 15 = 255. Above 9, letters serve as digits: A is 10, F is 15, Z is 35, which is why base 36 is the largest one.

In code, a prefix tells the base: 0b1010 for binary, 0o17 for octal (or a leading zero in C), 0xFF for hexadecimal. Most languages also accept underscores as separators, as in 1_000_000; this converter reads them too, and the numbers can be as large as you like.

Hexadecimal in colors and memory addresses

One hexadecimal digit is exactly 4 bits, two digits make a byte. That is why hexadecimal is everywhere bytes are shown: CSS colors (#FF8800 is red 255, green 136, blue 0), memory addresses (0x7FFE5A3C), MAC addresses, hashes from the hash generator, and the escapes of the URL encoder.

Octal digits are 3 bits each, which fits Unix permissions: in 755, each digit holds the read, write and execute bits of one class of users. The chmod calculator explains them.

Negative numbers and two’s complement

Processors store a negative integer in two’s complement: invert all the bits of the positive value, then add 1. In 8 bits, -1 is 1111 1111 (FF) and -42 is 1101 0110 (D6). The leftmost bit gives the sign, so a signed byte goes from -128 to 127, and the same bits read as unsigned go from 0 to 255.

The table of fixed-size integers shows both readings: FF is 255 unsigned but -1 in a signed byte. This explains overflows, such as a counter jumping from 2147483647 to -2147483648 in a 32-bit integer.

From 0 to 16 in the usual bases

DecimalBinaryOctalHexadecimal
0000000
1000111
2001022
3001133
4010044
5010155
6011066
7011177
81000108
91001119
10101012A
11101113B
12110014C
13110115D
14111016E
15111117F
16100002010

Add this browser’s favorites to your account?

This browser has 0 favorites that your account does not have:

Either way, this browser keeps its favorites: you find them again after signing out.