The same integer in four bases
Convert binary, octal, decimal, and hex
255, 0xFF, and 11111111 are one integer written three ways. This page keeps that integer exact and shows the other spellings beside the field you edit.
Pick the base of the field you are typing in. The other three update from it. Underscores may separate groups and are ignored. A leading 0b, 0o, or 0x is accepted when it matches the selected base. A minus sign is allowed. Digits that do not exist in that base, such as 2 in binary, are rejected. The value is a BigInt, so a 256-bit mask does not round through a JavaScript number. Fractions and hex floats are not accepted.
The conversion is arithmetic in this tab. The number is not sent anywhere.
This tool runs in your browser. Turn on JavaScript to use it.
Two hundred fifty-five
Hex pairs are a common way to read a byte. 255 fills eight bits.
- Decimal
- 255
- Hex
- ff
- Binary
- 11111111
- Octal
- 377
How to use it
- 1Choose the base you are about to type.
- 2Enter the digits. The other bases fill in.
- 3Copy the spelling you need. Hex is lower case.
Good to know
- Octal 377 is decimal 255, not a three-digit decimal.
- A leading zero does not switch the base. The selector does.
- Negative numbers carry the minus sign in every base. There is no two's-complement width.
Questions
Why is there no floating point?
Bases for fractions need a defined rounding. This page is for integers only.
Can I convert a color?
A hex byte such as ff works here. A #rrggbb color belongs on the color page, which keeps the three channels apart.
How large can the integer be?
As large as the tab can hold. It is not clipped to 32 or 64 bits.
Related tools
- Encode text as hexadecimal
Hex is a way to show raw bytes. This page encodes text as UTF-8 first, then prints each byte. Decoding accepts only an even number of digits and rejects bytes that are not UTF-8.
- Calculate chmod permissions
chmod talks in octal and in letters. This page shows both for the same bits, including the extra digit for setuid, setgid, and the sticky bit.
- Convert a color
The same color is written as hex, RGB, or HSL depending on the file. This page parses one of those forms and prints the other two.