Convert Decimal to Hex
255 in decimal is ff in hexadecimal, so converting decimal to hex changes the digits and nothing else: both are the same quantity, 255.
In decimal
- In binary
- 11111111
- In octal
- 377
- In decimal The value as entered.
- 255
- In hexadecimal
- ff
- Grouped Binary in nibbles of four and hex in bytes of two, which is how both are actually read. Each hex digit is exactly four binary digits, so the two groupings line up. That correspondence is the whole reason hexadecimal exists.
- 1111 1111 | ff
- Fits in Unsigned. A value needing more than 53 bits cannot be held exactly in a JavaScript number, which is why this converter works in BigInt. A float-based converter is silently wrong in the last digits above that.
- 8 bits
- As a character Read as a Unicode code point. This is the 'binary to text' conversion, one character at a time: 65 is A, 97 is a, and the 32 between them is why setting the sixth bit changes case in ASCII.
- U+00FF ΓΏ
How the Number Base Converter works
255 in decimal is ff in hexadecimal. Both spellings describe the same quantity, 255, and the conversion changes nothing except how it is written.
Every base works the same way: a digit's worth is the base times the worth of the digit to its right. In decimal each position is 10 times the last, so 255 reads as 2x10^2 + 5x10^1 + 5x10^0, which comes to 255.
Divide by sixteen and keep the remainders, or go through binary: split the bits into groups of four from the right and write each group as one hex digit. The second method is faster by hand and it is why hex exists at all. The common direction in practice is color: a CSS channel runs 0 to 255, so 128 becomes 80 and the mid gray everyone writes as #808080 is three channels of 128. Note that rounding a percentage into a channel is where web colors drift: 50% is 127.5, and whether that lands on 7F or 80 depends on the tool.
In binary the same value is 1111 1111, which is where both of these bases ultimately resolve. Everything a machine stores is bits, and every other base here is a way of writing them that a person can hold in their head.
One limit worth knowing about converters generally. A value above 2^53 cannot be held exactly in a floating-point number, and most online converters are built on them, so a 64-bit hash or identifier comes back with its last digits silently wrong. This converter uses arbitrary-precision integers, so the conversion is exact at any size.
Number Base Converter FAQ
What is 255 in hexadecimal?
ff. In decimal that is 255, and in the other two bases 11111111 and 377.
How do I convert decimal to hexadecimal by hand?
Divide by sixteen and keep the remainders, or go through binary: split the bits into groups of four from the right and write each group as one hex digit. The second method is faster by hand and it is why hex exists at all. The common direction in practice is color: a CSS channel runs 0 to 255, so 128 becomes 80 and the mid gray everyone writes as #808080 is three channels of 128. Note that rounding a percentage into a channel is where web colors drift: 50% is 127.5, and whether that lands on 7F or 80 depends on the tool.
Why does this matter outside programming?
Mostly it does not, but two cases leak out. CSS colors are hexadecimal, so anyone adjusting a shade by hand is doing this conversion. And file permissions on any Unix machine are octal, which is why chmod takes numbers like 755.
Will this be exact for very large numbers?
Yes. The arithmetic here is arbitrary-precision, so there is no point at which digits start being approximated. Converters built on ordinary floating-point numbers lose exactness above 2^53, which 64-bit identifiers routinely exceed.