Value of a number written in base b
N = Σ d_i × b^i (i from 0 to n − 1)
Each digit is multiplied by the power of b of its place, the rightmost digit having place 0.
Number base converter from 2 to 36: 255 = FF in hexadecimal = 11111111 in binary = 377 in octal. Positional notation, division method, #RRGGBB colours, chmod 755 permissions and bit masks.
Enter an integer in any base from 2 to 36 and read it at once in binary, octal, decimal and hexadecimal, plus the target base of your choice. Use it to decode a #RRGGBB colour, read Unix permissions like chmod 755, write a bit mask, check a number-systems exercise or handle base-36 identifiers.
In a positional system of base b, each digit is worth its place value, a power of b: 1F4 in base 16 equals 1 × 256 + 15 × 16 + 4 = 500. Bases above 10 use letters: A = 10, B = 11, up to F = 15 in hexadecimal and Z = 35 in base 36. Case is ignored when you type.
To go from decimal to base b, divide repeatedly by b and read the remainders from bottom to top: 500 = 31 × 16 + 4, then 31 = 1 × 16 + 15, so 1F4. Binary, octal and hexadecimal are linked because 8 = 2^3 and 16 = 2^4: one octal digit is 3 bits and one hex digit is 4 bits. So binary 1010 1010 groups into A and A, giving AA, or 170 in decimal.
Calculations use arbitrary-size integers: 18446744073709551615 (2^64 − 1) converts exactly to FFFFFFFFFFFFFFFF, which an ordinary JavaScript number cannot represent. The prefixes 0b, 0o and 0x are accepted for bases 2, 8 and 16, and spaces or underscores are ignored. A leading minus or plus sign is accepted.
Limits: only integers are handled, so fractional values such as 3.5 are rejected. A negative number is displayed with its sign (−42 gives −101010), not in two's complement, which depends on a chosen bit width. A digit that does not exist in the source base, such as 2 in binary, is reported.
Type the integer (with or without a 0x, 0b or 0o prefix) and pick the source base: 2, 8, 10, 16, 36 or a custom value from 2 to 36.
Binary, octal, decimal and hexadecimal results are always shown, and the target base appears in its own field.
Choose upper or lower case, and group digits by 4 (binary, hex) or 3 to make long values easier to read.
An integer N is written in base b with digits d_i between 0 and b − 1.
N = Σ d_i × b^i (i from 0 to n − 1)
Each digit is multiplied by the power of b of its place, the rightmost digit having place 0.
N = q × b + r
The remainder r is the lowest digit in base b; repeat with q.
16 = 2^4 and 8 = 2^3
One hex digit equals 4 bits and one octal digit 3 bits.
Example: 500 ÷ 16 = 31 remainder 4; 31 ÷ 16 = 1 remainder 15 (F); 1 ÷ 16 = 0 remainder 1. Reading the remainders from bottom to top, 500 = 1F4 in hexadecimal.
Decode a #RRGGBB code into three decimal values from 0 to 255, or the other way round.
Read an octal chmod mode as a sequence of r, w and x bits.
Write a bit mask, read a memory value or understand a binary field.
Check number-system exercises or compare the representations of one integer.
255 = 15 × 16 + 15, the largest value of one byte.
Input
255 (base 10)Result
FF in hexadecimal, 11111111 in binary, 377 in octalFF = 255 (red), 88 = 136 (green), 00 = 0 (blue): rgb(255, 136, 0).
Input
FF8800 (base 16)Result
16746496 in decimal7 = 111 (rwx), 5 = 101 (r-x), 5 = 101 (r-x): rwxr-xr-x.
Input
755 (base 8)Result
111101101 in binary, 493 in decimalSpaces are ignored, and each group of 4 bits gives one hex digit.
Input
1010 1010 (base 2)Result
AA in hexadecimal, 170 in decimal1000 = 27 × 36 + 28, with R = 27 and S = 28.
Input
1000 (base 10)Result
RS in base 36Divide by 2, note the remainders, and read them from bottom to top. For example 13 gives 1101: 13 = 6 × 2 + 1, 6 = 3 × 2 + 0, 3 = 1 × 2 + 1, 1 = 0 × 2 + 1.
Multiply each digit by a power of 16. FF = 15 × 16 + 15 = 255, and 1F4 = 1 × 256 + 15 × 16 + 4 = 500.
All integer bases from 2 to 36, including binary (2), octal (8), decimal (10), hexadecimal (16) and base 36 (digits 0-9 then A-Z).
Negatives are accepted with a minus sign and shown with their sign (−42 gives −101010), without two's complement. Fractional numbers are not accepted.
Not in practice: the calculation uses arbitrary-size integers. 2^64 − 1 = 18446744073709551615 gives FFFFFFFFFFFFFFFF.
Related tools
Tools similar or complementary to this one.
Convert a color between HEX, RGB, and HSL with equivalent values.
Encode text as Base64 or decode a Base64 string back to its original content.
Write a number in words in English, French, Spanish, German, Italian or Portuguese, or turn written words back into digits.