Number Conversion
conversion / numberAll bases
Number Conversion
Convert numbers between any two bases from 2 to 36, including binary, octal, decimal and hexadecimal. Enter a value in one base and read the equivalent in another — useful for reading memory addresses, decoding color values, working with file permissions, or checking bitmask flags. Negative and fractional values are supported, large integers keep their exact value rather than rounding, and every common base is shown at once. The conversion runs in your browser.
Supported numeral systems
A base is simply how many distinct digits a system has before it must carry into the next column. Every base below represents exactly the same numbers — only the notation changes.
| Base | Radix | Prefix | Digits |
|---|---|---|---|
| Binary | 2 | 0b | 01 |
| Octal | 8 | 0o | 01234567 |
| Decimal | 10 | — | 0123456789 |
| Hexadecimal | 16 | 0x | 0123456789abcdef |
Binary
The binary system uses only two digits, 0 and 1, and each digit is called a bit. Every position is a power of two, which is what makes it the natural system for hardware: a circuit only has to distinguish two voltage levels.
The binary number 1011 is 1×2³ + 0×2² + 1×2¹ + 1×2⁰ = 8 + 0 + 2 + 1 = 11 in decimal.- Computing
- The foundation of digital computing, where hardware processes data as bits.
- Storage
- How data is physically represented on drives and in memory.
- Logic circuits
- Logic gates and the circuits built from them operate on binary values.
Octal
The octal system uses eight digits, 0 to 7, and each position is a power of eight. One octal digit stands for exactly three bits, which made it a compact shorthand for binary before hexadecimal displaced it.
The octal number 17 is 1×8¹ + 7×8⁰ = 8 + 7 = 15 in decimal.- Unix file permissions
- Modes such as 755 group the read, write and execute bits three at a time.
- Historical computing
- A shorthand for binary on machines with word sizes divisible by three.
- Memory addressing
- Used for addressing and organising data on some older systems.
Decimal
The decimal system uses ten digits, 0 to 9, with each position a power of ten. It is the standard system for everyday counting and arithmetic, and is thought to be near-universal among human cultures because we have ten fingers.
The decimal number 345 is 3×10² + 4×10¹ + 5×10⁰ = 300 + 40 + 5 = 345.- Everyday life
- The standard system for counting, measuring and daily arithmetic.
- Mathematics and science
- Used universally in mathematics, engineering and scientific work.
- Currency
- Most modern currencies are subdivided decimally.
Hexadecimal
The hexadecimal system uses sixteen digits: 0 to 9, then A to F for the values ten to fifteen. One hex digit is exactly four bits, so a byte is always two hex digits — which is why it is the usual way to write binary data for humans.
The hexadecimal number 1A3 is 1×16² + 10×16¹ + 3×16⁰ = 256 + 160 + 3 = 419 in decimal.- Computing
- A compact way to write binary data; every four bits is one hex digit.
- Memory addresses
- Pointers and addresses are shown in hex because it is easier to read than binary.
- Colour codes
- Web colours pair the red, green and blue channels as hex, such as #FF5733.
How base conversion works
JavaScript numbers are IEEE 754 doubles, so an integer above 2⁵³ − 1 cannot be represented exactly — see ECMA-262. This tool converts with arbitrary-precision arithmetic instead, so a 40-digit value survives the round trip that a naive implementation would silently corrupt.
A digit string in base b denotes the sum of each digit multiplied by a power of b, counting from zero at the right. That single definition is the whole of positional notation, and it is why converting is mechanical rather than a matter of lookup.
How positional notation works
Every one of these systems works the same way. Each digit position carries a weight that is a power of the base, and the value of the number is the sum of each digit multiplied by its position's weight. Only the base changes.
In decimal, 237 means 2×10² + 3×10¹ + 7×10⁰. In binary, 1101 means 1×2³ + 1×2² + 0×2¹ + 1×2⁰, which comes to 13. The mechanism is identical; the digits available and the multiplier differ.
That is why the same quantity looks so different across bases. The number thirteen is 13 in decimal, 1101 in binary, 15 in octal, and D in hexadecimal — one value, four representations.
Why each base exists
Binary
Two digits, 0 and 1, matching the two states a circuit can reliably distinguish: current or no current. Everything a computer stores is ultimately binary; the other bases here are conveniences for humans reading that data.
Octal
Eight digits, each one standing for exactly three bits. Its most visible survival is Unix file permissions, where chmod 755 encodes three groups of three permission bits — read, write, execute — as three octal digits.
Decimal
Ten digits, near-universal among humans for the obvious anatomical reason. It has no special relationship to computer hardware, which is exactly why conversion is needed so often.
Hexadecimal
Sixteen digits — 0-9 then A-F — each representing exactly four bits, so one byte is always two hex digits. This tidy mapping is why memory addresses, color codes, and byte dumps are written in hex: it is far more compact than binary while still lining up cleanly with the underlying bits.
Reference table
The first sixteen values in each base:
- 0-3— binary 0, 1, 10, 11; octal 0, 1, 2, 3; hex 0, 1, 2, 3
- 4-7— binary 100, 101, 110, 111; octal 4, 5, 6, 7; hex 4, 5, 6, 7
- 8-11— binary 1000, 1001, 1010, 1011; octal 10, 11, 12, 13; hex 8, 9, A, B
- 12-15— binary 1100, 1101, 1110, 1111; octal 14, 15, 16, 17; hex C, D, E, F
Notice that four binary digits map onto exactly one hex digit. Converting between binary and hexadecimal is therefore just grouping bits into fours, with no arithmetic required — which is the whole reason programmers prefer hex to binary.
Common uses
- Web colors—
#FF8800is three bytes: red 255, green 136, blue 0. - File permissions— reading and writing Unix modes such as 644 or 755.
- Memory addresses and debugging— stack traces, hex dumps, and pointer values.
- Bitmasks and flags— seeing which individual bits a configuration value has set.
- Network addressing— subnet masks make far more sense read as binary.
- Character encodings— Unicode code points are conventionally written in hex, as in U+00E9.
Common pitfalls
- A leading zero can mean octal.In several programming languages
0755is not seven hundred fifty-five. This has caused real bugs. - Hex letters are digits, not text.In
2Fthe F is the value fifteen, not a letter. - Watch the prefixes.
0bmarks binary,0ooctal, and0xhexadecimal. They label the notation and are not part of the value. - A digit must be valid for its base.There is no digit 8 in octal and no 2 in binary; such input is not a number in that base at all.
- Case does not matter in hex.
ffandFFare the same value, though a given codebase usually settles on one.
Frequently asked questions
Which bases are supported?
Can I convert negative or fractional numbers?
10.25 in decimal is 1010.01 in binary. Bear in mind that a fraction which terminates in one base often repeats forever in another — one tenth is exact in decimal but repeats in binary, the same way one third repeats in decimal — so such results are rounded rather than exact.Are very large numbers accurate?
ffffffffffffffff converts to exactly 18446744073709551615 instead of being rounded off at the seventeenth digit.Why do computers use binary rather than decimal?
Why is hexadecimal preferred over binary for display?
What does the "0x" in front of a number mean?
10 is ambiguous — sixteen in hex, ten in decimal, two in binary. The prefix removes the ambiguity and is not part of the number itself.Can I convert negative numbers or fractions?
Is octal still used?
Standards and references
- IEEE 754-2019 IEEE Standard for Floating-Point Arithmetic 2019
- ECMA-262 ECMAScript Language Specification — Number and BigInt semantics