About this tool
A number base converter: type an integer in the binary, octal, decimal, hexadecimal or any base 2–36 field and every other base updates at once. It uses BigInt, so values up to 4,096 decimal digits stay exact; it accepts 0b, 0o and 0x prefixes, underscores and negative numbers, and shows the two’s-complement pattern for 8, 16, 32 and 64 bits.
Typical uses
- Turn a hex color, memory address or error code into decimal
- See the two’s-complement bits of a negative number in an 8-bit or 32-bit integer
- Check how a big integer ID above 2^53 is written in other bases
How to use
Type an integer in any field: binary, octal, decimal, hexadecimal, or any base from 2 to 36 picked in the menu. Prefixes 0b, 0o and 0x, spaces or underscores as separators and a minus sign are accepted.
The other fields update as you type; choose upper-case letters, prefixes and grouping, then copy any field. Under “Two’s complement”, pick 8, 16, 32 or 64 bits to see the bit pattern and its signed and unsigned readings.
Uses BigInt, so every integer below 10^4096 (up to 4,096 decimal digits) converts exactly, with none of the precision loss ordinary JavaScript numbers have above 2^53 − 1. Whole numbers only, no fractions. Values outside the chosen width are reported as an overflow and only the low bits are shown. Runs in your browser.
Positional notation: one number, many spellings
A base (radix) sets the weight of each position. In base b, the k-th digit from the right (counting from 0) is worth b^k, and the value is the sum of each digit times its weight. Hexadecimal writes 10–15 as A–F and base 36 goes up to Z (35), so 2–36 are all the bases that “0–9 plus 26 letters” can spell. Examples: hex 2F: 2×16¹ + 15×16⁰ = 47; binary 1011: 1×2³ + 0×2² + 1×2¹ + 1×2⁰ = 11; octal 755: 7×8² + 5×8¹ + 5×8⁰ = 493; base-36 ZZ = 1295.
| Decimal | Binary (4 bits) | Octal | Hex |
|---|---|---|---|
| 0 | 0000 | 0 | 0 |
| 1 | 0001 | 1 | 1 |
| 2 | 0010 | 2 | 2 |
| 3 | 0011 | 3 | 3 |
| 4 | 0100 | 4 | 4 |
| 5 | 0101 | 5 | 5 |
| 6 | 0110 | 6 | 6 |
| 7 | 0111 | 7 | 7 |
| 8 | 1000 | 10 | 8 |
| 9 | 1001 | 11 | 9 |
| 10 | 1010 | 12 | A |
| 11 | 1011 | 13 | B |
| 12 | 1100 | 14 | C |
| 13 | 1101 | 15 | D |
| 14 | 1110 | 16 | E |
| 15 | 1111 | 17 | F |
| 16 | 10000 | 20 | 10 |
This table and every figure below are computed by the tool’s own conversion functions when the page is built.
Powers of two and common values
| Power | Decimal | Hex |
|---|---|---|
| 2^4 | 16 | 0x10 |
| 2^8 | 256 | 0x100 |
| 2^10 | 1024 | 0x400 |
| 2^16 | 65536 | 0x1 0000 |
| 2^24 | 16777216 | 0x100 0000 |
| 2^31 | 2147483648 | 0x8000 0000 |
| 2^32 | 4294967296 | 0x1 0000 0000 |
| 2^53 | 9007199254740992 | 0x20 0000 0000 0000 |
| 2^63 | 9223372036854775808 | 0x8000 0000 0000 0000 |
| 2^64 | 18446744073709551616 | 0x1 0000 0000 0000 0000 |
| Decimal | Binary | Octal | Hex |
|---|---|---|---|
| 255 | 1111 1111 | 377 | 0xFF |
| 256 | 1 0000 0000 | 400 | 0x100 |
| 1024 | 100 0000 0000 | 2000 | 0x400 |
| 65535 | 1111 1111 1111 1111 | 177777 | 0xFFFF |
| 2147483647 | 111 1111 1111 1111 1111 1111 1111 1111 | 17777777777 | 0x7FFFFFFF |
| 4294967295 | 1111 1111 1111 1111 1111 1111 1111 1111 | 37777777777 | 0xFFFFFFFF |
255 is a byte (8 bits) of ones; 65535 is the largest unsigned 16-bit integer; 2147483647 (0x7FFFFFFF) is the largest signed 32-bit integer and 4294967295 (0xFFFFFFFF) the largest unsigned one. 1024 = 2^10 is the step between KiB and bytes.
Why one hex digit is exactly four bits
16 = 2^4, so every hex digit stands for exactly 4 binary digits (a nibble), and conversion needs no division, only a digit-by-digit lookup. Likewise 8 = 2^3, so one octal digit is 3 bits. 0xDEADBEEF grouped by four is 1101 1110 1010 1101 1011 1110 1110 1111, or 3735928559 in decimal; octal 755 grouped by three is 111 101 101. Ten is not a power of two, so decimal has no such digit-to-bits mapping, which is why programmers read memory and bit masks in hex.
In the tool, “Binary groups” splits binary every 4 or 8 digits, “Hex groups” splits hex every 2 digits (one byte) or 4, and “Group separator” chooses a space or an underscore. “Upper-case letters (A–F)” sets the case of A–F, and “Show prefixes (0b, 0o, 0x)” adds 0b, 0o and 0x so results paste straight into code.
Two’s complement: how computers store negative numbers
Fixed-width integers store a negative value v in w bits as 2^w + v. In 8 bits, −1 is stored as 2^8 − 1 = 255, which is 1111 1111. By hand: “invert and add one”. 1 is 0000 0001; inverting every bit gives 1111 1110; adding 1 gives 1111 1111. A leading 1 means negative, so the same bits have two readings, “Read as signed” and “Read as unsigned”. The table comes from the tool’s “Two’s complement” panel:
| Value | Bits | Bit pattern | Hex | Read as unsigned |
|---|---|---|---|---|
| −1 | 8 | 1111 1111 | FF | 255 |
| −1 | 16 | 1111 1111 1111 1111 | FFFF | 65535 |
| −1 | 32 | 1111 1111 1111 1111 1111 1111 1111 1111 | FFFF FFFF | 4294967295 |
| −128 | 8 | 1000 0000 | 80 | 128 |
| −128 | 16 | 1111 1111 1000 0000 | FF80 | 65408 |
| −128 | 32 | 1111 1111 1111 1111 1111 1111 1000 0000 | FFFF FF80 | 4294967168 |
| 127 | 8 | 0111 1111 | 7F | 127 |
| 127 | 16 | 0000 0000 0111 1111 | 007F | 127 |
| 127 | 32 | 0000 0000 0000 0000 0000 0000 0111 1111 | 0000 007F | 127 |
| Width | Signed range | Unsigned range |
|---|---|---|
| 8 | −128 … 127 | 0 … 255 |
| 16 | −32768 … 32767 | 0 … 65535 |
| 32 | −2147483648 … 2147483647 | 0 … 4294967295 |
| 64 | −9223372036854775808 … 9223372036854775807 | 0 … 18446744073709551615 |
- 128 does not fit the signed 8-bit range but does fit the unsigned one: the pattern is 1000 0000, which reads as -128 when signed. In the same way 255 (0xFF) reads as -1.
- 256 is outside both 8-bit ranges. The tool reports the overflow and shows the low 8 bits, 0000 0000, which is exactly what a cast such as (byte) 256 in Java or (uint8_t) 256 in C produces.
- Widening a negative number fills with ones: −128 in 16 bits is 0xFF80. Extending signed data therefore needs sign extension, not zero padding.
JavaScript Number vs BigInt: why big numbers go wrong
A JavaScript Number is an IEEE 754 double with 53 significant bits. Number.MAX_SAFE_INTEGER is 9007199254740991, that is 2^53 − 1 (0x1FFFFFFFFFFFFF). Above it integers are no longer guaranteed exact: in a browser, Number('9007199254740993') gives 9007199254740992, and parseInt('ffffffffffffffff', 16) gives 18446744073709552000 while the true value is 18446744073709551615. This tool uses BigInt (arbitrary-precision integers) throughout, so values up to 4096 decimal digits (13607 binary digits) convert exactly.
- parseInt does not understand the 0b prefix: parseInt('0b101') returns 0, while BigInt('0b101') returns 5.
- Source code may use separators such as 1_000_000, but at run time Number('1_000') is NaN. This tool ignores underscores and spaces in what you type.
- Number.isSafeInteger(2 ** 53) is false. 64-bit IDs from a server should be kept as strings or parsed with BigInt.
Practical examples: file permissions, colors and 2038
Unix chmod writes permissions as three octal digits for owner, group and others. Each octal digit is exactly three bits: read (4), write (2) and execute (1).
| Octal | Binary | Permissions | Typical use |
|---|---|---|---|
| 755 | 111 101 101 | rwxr-xr-x | Directories and executable scripts |
| 644 | 110 100 100 | rw-r--r-- | Ordinary files |
| 600 | 110 000 000 | rw------- | Private keys and other owner-only files |
A web color #RRGGBB is three bytes in hex: #FF8800 splits into FF, 88 and 00, which is RGB(255, 136, 0); #336699 is RGB(51, 102, 153). The CSS short form #F80 doubles each digit, giving #FF8800.
0x7FFFFFFF = 2147483647 is the largest number of seconds a signed 32-bit integer can hold. Systems that store Unix time that way overflow after 2038-01-19T03:14:07Z (UTC): the “year 2038 problem”.
Input rules and limits
- Type in any field and the others update as you type. The binary, octal and hex fields accept their own 0b, 0o and 0x prefixes; a prefixed number such as 0x1F typed in the decimal field is read in the prefix’s base.
- Spaces and underscores between digits are ignored, a leading + or − sets the sign, and letters may be upper or lower case.
- A wrong digit is pointed out by position. Typing 102 in the binary field shows: ““2” is not a digit in base 2 (character 3). Allowed digits: 0–1.”
- Values must be below 10^4096. Whole numbers only: a decimal fraction like 0.1 repeats forever in binary and has no exact finite form.
- “Two’s complement” offers 8, 16, 32 and 64 bits (“Bit width”); the case of the hex pattern follows “Upper-case letters (A–F)”.
Sources
Frequently asked questions
What is −1 in binary?
Mathematically it is just −1. Computers store it in two’s complement: 1111 1111 (0xFF) in 8 bits, 0xFFFF FFFF in 32 bits. Pick the width under “Two’s complement” to see it.
Why does 0xFF show −1 in the two’s complement panel?
The same bits can be read as unsigned (255) or signed (−1). The tool shows both readings.
Can it convert fractions?
No, whole numbers only. Decimal fractions such as 0.1 repeat forever in binary and cannot be written exactly.
Suggest an improvement to this tool
Missing an option, something awkward to use, or a wrong result? Let us know.