Number Base Converter: Binary, Hex, Decimal
Convert integers of any size between binary, octal, decimal, hexadecimal and any base up to 36, then inspect the same value as two's-complement bits you can toggle, big- and little-endian bytes, and IEEE-754 floats from bfloat16 and float16 to float64, with a bitwise calculator alongside.
How positional number bases work
A base, or radix, is the number of distinct digits a system uses. In base 10 each position is worth ten times the one to its right; in base 2 each is worth twice as much, so 1011 is 8 + 0 + 2 + 1 = 11. Hexadecimal, base 16, uses the digits 0–9 and then A–F for ten to fifteen. It is popular in computing because one hex digit is exactly four bits, so a byte is always two hex digits and a 32-bit value is eight: 0xDEADBEEF is far easier to read than its 32 binary digits. Octal, base 8, maps three bits per digit and survives in Unix file permissions such as chmod 755.
Converting between any two bases means reading the digits into a single integer and writing it back out in the target base. This tool does that with JavaScript's BigInt, so there is no upper limit and no rounding: a 256-bit hash, a 20-digit account number or 264−1 converts exactly. Regular JavaScript numbers lose precision above 253, which is why pasting a large ID into many converters silently changes its last digits.
Two's complement and fixed widths
Computers store integers in a fixed number of bits, and almost all of them represent negative numbers with two's complement: the most significant bit carries a negative weight. In 8 bits, 11111111 is 255 read as unsigned but −1 read as signed, and 10000000 is 128 or −128. The same bit pattern means different things depending on the type you read it as, which is the source of many overflow bugs. The bits panel shows both readings at the chosen width, flags values that do not fit, and lets you flip individual bits to see the effect, which is useful when working with flags, masks and hardware registers.
| Width | Unsigned range | Signed range | Common type |
|---|---|---|---|
| 8-bit | 0 to 255 | −128 to 127 | uint8 / int8, byte, char |
| 16-bit | 0 to 65,535 | −32,768 to 32,767 | uint16 / short, UTF-16 code unit |
| 32-bit | 0 to 4,294,967,295 | −2,147,483,648 to 2,147,483,647 | uint32 / int, IPv4 address, Unix time (signed) |
| 64-bit | 0 to 18,446,744,073,709,551,615 | ±9.22 × 1018 | uint64 / long, database BIGINT |
Byte order
A multi-byte value has to be laid out in memory in some order. Big-endian puts the most significant byte first, the way we write numbers; it is the network byte order used by TCP/IP headers and most file formats. Little-endian puts the least significant byte first, and is what x86 and ARM processors use in memory. The value 0x12345678 is stored as 12 34 56 78 big-endian and 78 56 34 12 little-endian. When a hex dump of a file or packet does not match the number you expected, reversing the byte order is the first thing to try; both layouts are shown side by side.
Floating point bits
At 32 and 64 bits the same pattern can also be read as an IEEE-754 floating-point number, the format used by float and double in nearly every language. At 16 bits it is read two ways: as IEEE half precision (float16: 5 exponent bits, 10 mantissa bits, largest value 65504), used in graphics and for storing model weights, and as bfloat16 (8 exponent bits like float32, 7 mantissa bits), which machine-learning hardware uses because it keeps float32's range. Converting a decimal to either rounds once, to nearest with ties to even, as the hardware does. The bits split into a sign, an exponent and a mantissa. The panel decodes them and reports whether the value is normal, subnormal, zero, infinity or NaN. Use the decimal-to-bits field to see why 0.1 cannot be stored exactly: its float64 pattern is 0x3FB999999999999A, a repeating binary fraction rounded at the last bit, which is why 0.1 + 0.2 is not exactly 0.3.
Binary, octal, decimal and hex conversion table
The values you meet most often in code, with their binary, octal and hexadecimal forms. Type any other number into the converter above, in any base up to 36 and of any size.
| Decimal | Binary | Octal | Hex |
|---|---|---|---|
| 0 | 0 | 0 | 0 |
| 1 | 1 | 1 | 1 |
| 2 | 10 | 2 | 2 |
| 3 | 11 | 3 | 3 |
| 4 | 100 | 4 | 4 |
| 5 | 101 | 5 | 5 |
| 6 | 110 | 6 | 6 |
| 7 | 111 | 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 |
| 31 | 11111 | 37 | 1F |
| 32 | 100000 | 40 | 20 |
| 63 | 111111 | 77 | 3F |
| 64 | 1000000 | 100 | 40 |
| 100 | 1100100 | 144 | 64 |
| 127 | 1111111 | 177 | 7F |
| 128 | 10000000 | 200 | 80 |
| 255 | 11111111 | 377 | FF |
| 256 | 100000000 | 400 | 100 |
| 1000 | 1111101000 | 1750 | 3E8 |
| 1023 | 1111111111 | 1777 | 3FF |
| 1024 | 10000000000 | 2000 | 400 |
| 4095 | 111111111111 | 7777 | FFF |
| 65535 | 1111111111111111 | 177777 | FFFF |
How to convert binary to decimal
Write the place value of each bit from the right (1, 2, 4, 8, 16...) and add up the places that hold a 1. For 101101: 32 + 8 + 4 + 1 = 45.
How to convert decimal to binary
Divide by 2 repeatedly and write the remainders from last to first. 45 ÷ 2 = 22 r 1, 22 ÷ 2 = 11 r 0, 11 ÷ 2 = 5 r 1, 5 ÷ 2 = 2 r 1, 2 ÷ 2 = 1 r 0, 1 ÷ 2 = 0 r 1, so 45 is 101101.
How to convert hex to decimal
Each hex digit is worth 16 times the one to its right, with A to F standing for 10 to 15. For 0x2F: 2 × 16 + 15 = 47. Going the other way, each hex digit is exactly four bits, so 0x2F is 0010 1111 in binary, which is why hex is the usual shorthand for bytes.
Frequently asked questions
Multiply each hex digit by 16 raised to its position, counting from zero on the right, and add the results. For 0x2F3 that is 2 × 256 + 15 × 16 + 3 × 1 = 755, using A = 10 through F = 15. Typing 0x2F3, or 2F3 with the input base set to hex, into the converter shows 755 along with binary, octal and every other base, with no limit on the number of digits.
Negative integers are normally stored in two's complement at a fixed width. Write the positive value in binary, invert every bit, and add one. For −5 in 8 bits: 5 is 00000101, inverted 11111010, plus one is 11111011, which is 0xFB. Enter −5 and pick a width in the bits panel to see the two's-complement bits, the unsigned reading of the same bits (251 at 8-bit) and the bytes in both byte orders.
Most web converters and spreadsheets use 64-bit floating point numbers, which can represent every integer exactly only up to 2 to the power 53, about 9 quadrillion. Beyond that, digits are rounded, so a 19-digit Twitter/X or Discord snowflake ID, a 64-bit database key or a hash prefix comes back altered. This tool parses and formats with arbitrary-precision BigInt arithmetic, so every digit is preserved at any size.
Any integer base from 2 to 36, using the digits 0–9 followed by the letters A–Z. Binary, octal, decimal, hexadecimal and base 36 are always shown; set "Also show base" for another, for example base 3 or base 32. Input accepts 0x, 0b and 0o prefixes, an assembler-style h suffix in auto mode, and underscores, commas, spaces or apostrophes as digit separators, so values copied from code or documentation paste cleanly.
They are two readings of the same bits. Unsigned treats every bit as positive, so 8 bits hold 0 to 255. Signed two's complement gives the top bit a negative weight, so 8 bits hold −128 to 127. The pattern 11111111 is 255 unsigned and −1 signed. Bugs appear when a value written as one type is read as the other, for example a length of 200 stored in a signed byte reading back as −56.
Both are 16 bits. float16, or IEEE half precision, spends 5 bits on the exponent and 10 on the mantissa: about three significant decimal digits, but the largest value is only 65504 and small values become subnormal below 6.1e-5. bfloat16 keeps float32's 8 exponent bits and keeps only 7 mantissa bits: about two significant digits, but the same range as float32, up to 3.4e38, which is why training hardware prefers it. Choose 16-bit width to read a pattern both ways, or pick float16 or bfloat16 next to the decimal box to see how a number is stored and rounded.
No. Parsing, conversion, two's complement, byte order, float decoding and the calculator all run in JavaScript on this page. There are no network requests, and the page continues to work offline once it has loaded.
Changelog
- v1.1.0 float16 (IEEE half precision) and bfloat16: at 16-bit width the bits are decoded both ways, and decimals encode to either with round-to-nearest-even, subnormals and overflow to infinity. Every one of the 65,536 float16 patterns is checked to round-trip.
- v1.0.0 Initial release: arbitrary-precision conversion in bases 2–36 with prefix, suffix and separator parsing, two's complement at 8–128 bits with overflow detection, clickable bit grid, big- and little-endian bytes with ASCII, IEEE-754 float32/float64 decoding and encoding, and a bitwise and arithmetic calculator.