Number System Converter: Binary, Octal, Decimal, Hex and Roman Numerals
By FindMySum · Last reviewed
A number system converter rewrites a whole number in a different base without changing its value. Forty-two is the same quantity whether you write it as 42 in decimal, 101010 in binary, 52 in octal, 2A in hexadecimal or XLII in Roman numerals. This converter takes a value in any of those five systems and shows it in all the others at once. The four positional systems follow one rule, so once you see how it works you can check any conversion by hand; Roman numerals follow different rules, which explains their limits.
How positional number systems work
In a positional system, each digit is multiplied by a power of the base, and the power depends on the digit's position, counting from 0 on the right. In decimal, 352 means 3 × 10² + 5 × 10¹ + 2 × 10⁰. The same rule works in any base:
| System | Base | Digits | Common use |
|---|---|---|---|
| Binary | 2 | 0 and 1 | How computers store everything |
| Octal | 8 | 0 to 7 | Unix file permissions |
| Decimal | 10 | 0 to 9 | Everyday counting |
| Hexadecimal | 16 | 0 to 9, A to F | Colours, memory addresses, byte values |
Hexadecimal needs six extra digits, so it borrows letters: A is 10, B is 11 and so on up to F for 15.
To convert from another base to decimal, multiply each digit by its place value and add. To convert from decimal to another base, divide by the base repeatedly and keep the remainders; read them from last to first. The converter works with exact whole-number arithmetic, so it keeps every digit for values up to 64 digits long instead of rounding them the way ordinary floating-point numbers do above 2⁵³.
Worked example: the calculator's defaults
The converter opens with the decimal value 42.
To binary, divide by 2 and note each remainder:
- 42 ÷ 2 = 21, remainder 0
- 21 ÷ 2 = 10, remainder 1
- 10 ÷ 2 = 5, remainder 0
- 5 ÷ 2 = 2, remainder 1
- 2 ÷ 2 = 1, remainder 0
- 1 ÷ 2 = 0, remainder 1
Reading the remainders from the bottom up gives 101010. Check it the other way: 32 + 8 + 2 = 42.
To octal: 42 ÷ 8 = 5 remainder 2, and 5 ÷ 8 = 0 remainder 5, so the result is 52 (5 × 8 + 2 = 42).
To hexadecimal: 42 ÷ 16 = 2 remainder 10, and 10 is written A, so the result is 2A (2 × 16 + 10 = 42).
To Roman numerals: 42 is 40 + 2. Forty is written XL (10 before 50) and 2 is II, giving XLII.
Shortcuts between binary, octal and hex
Because 8 = 2³ and 16 = 2⁴, you can convert binary to octal or hex without going through decimal. Group the bits from the right in threes for octal or fours for hex, and convert each group on its own. Take the year 2026, which the converter shows as binary 11111101010:
- Fours for hex: 111 1110 1010 → 7, E, A → 7EA
- Threes for octal: 11 111 101 010 → 3, 7, 5, 2 → 3752
- Roman: MMXXVI
This is why programmers like hexadecimal: each hex digit stands for exactly four bits, so two hex digits describe one byte, and a long binary pattern becomes short enough to read.
How Roman numerals are built
Roman numerals are additive, not positional. Seven symbols carry fixed values (I = 1, V = 5, X = 10, L = 50, C = 100, D = 500, M = 1,000), and you add them up from largest to smallest. The modern standard form adds six subtractive pairs, where a smaller symbol written before a larger one is subtracted: IV (4), IX (9), XL (40), XC (90), CD (400) and CM (900). Only I, X and C are subtracted, and only from the next two larger symbols.
The converter accepts only numerals written in this standard form. It rejects variants such as IIII, which appears on many clock faces, and IC for 99, telling you the standard spelling instead. Standard numerals stop at 3,999 (MMMCMXCIX) because there is no symbol above M; larger values were written with a bar over a numeral to multiply it by 1,000, a convention the converter doesn't use. There is also no Roman numeral for zero, so for 0 or anything above 3,999 the Roman result shows as not available.
Limits
The converter handles whole numbers from 0 upward. It doesn't convert negative numbers, which computers store using a fixed-width scheme such as two's complement, or fractions, which computers usually store as binary floating-point values under IEEE 754. Values can be up to 64 digits long in the base you type, and every digit of the result is exact.
Using the result
For arithmetic on the converted numbers, the basic calculator works in decimal. Powers of 2 and their logarithms, which tell you how many bits a number needs, are in the exponent and logarithm calculator. For storage sizes, remember the NIST binary prefixes: a kibibyte is 2¹⁰ bytes, a mebibyte 2²⁰ and a gibibyte 2³⁰.
More questions
How do I read a hex colour code like #1E90FF?
Split it into three pairs, one each for red, green and blue, and convert each pair from hexadecimal. 1E is 30, 90 is 144 and FF is 255, so the colour is red 30, green 144, blue 255 on a 0 to 255 scale, a bright blue. Each pair is one byte, which is why colours have exactly six hex digits.
Why does a byte only go up to 255?
A byte is 8 bits, and the largest 8-digit binary number is 11111111, which the converter shows as 255 in decimal, 377 in octal and FF in hexadecimal. Counting from 0, that gives 256 possible values, which is 2 to the power 8. The same pattern holds for any width: n bits hold values from 0 to 2ⁿ − 1.
Does the converter keep leading zeros?
Leading zeros don't change a value, so they are accepted but not kept. Binary 00101010 converts to 42, and the binary result is shown as 101010. If you need a fixed width, such as 8 bits for a byte, add zeros to the left of the result yourself until it is the right length.
What is the difference between a kilobyte and a kibibyte?
A kilobyte (kB) is 1,000 bytes, using the SI prefix kilo. A kibibyte (KiB) is 1,024 bytes, or 2¹⁰. The binary prefixes kibi, mebi and gibi were adopted by the International Electrotechnical Commission in 1998 to end the confusion, and NIST recommends them. The gap grows with size: a gibibyte is about 7.4% larger than a gigabyte.
How do I write a year like 1999 in Roman numerals?
Break it into thousands, hundreds, tens and ones and write each part separately: 1000 is M, 900 is CM, 90 is XC and 9 is IX, giving MCMXCIX. The converter does this for any whole number from 1 to 3,999. A tempting shortcut, MIM (1000 + 999), is not standard, because I may only be subtracted from V and X.
Is hexadecimal input case-sensitive?
No. The letters A to F can be typed in upper or lower case, so 2a and 2A are the same value, 42. The converter always shows hexadecimal results in upper case. Spaces and underscores used to group digits, as in 1010_1010, are ignored.
Sources
This article explains how the calculator works and is general information, not financial, tax, legal or medical advice. Rules change; check the sources above or a qualified professional before you act.