Advertisement

Decimal to hexadecimal converter

Enter a decimal integer to encode it in base sixteen. The binary cross-check can use a fixed unsigned word size.

Calculator

Decimal integer
255
Binary representation
11111111
Octal representation
377
Hexadecimal representation
FF
Minimum unsigned bits
8
Same integer in four bases
BaseRepresentation
Decimal (10)255
Binary (2)11111111
Octal (8)377
Hexadecimal (16)FF

Advertisement

How this calculator works

Repeated division by sixteen produces remainders from 0 to 15; reading them backwards gives hexadecimal digits. Values 10 through 15 become A through F. Reverse conversion sums powers of sixteen. The word-width selector pads the binary check and verifies that the integer fits, without changing its hexadecimal value. Exact integer arithmetic preserves values beyond the usual safe JavaScript number range.

Formula

N = 16q + r. Repeat on q and read remainders in reverse order, using A=10, B=11, C=12, D=13, E=14 and F=15.

Worked example

255 divided by 16 gives quotient 15 and remainder 15: FF. Hex 100 means 1 x 256 = 256; its 16-bit binary check is 0000000100000000.

Advertisement

Frequently asked questions

Does the word size change hex digits?

It checks overflow and pads the binary cross-check. The hexadecimal result stays in its shortest unsigned form.

Can I convert decimal fractions?

This focused tool accepts whole non-negative integers. Fractional base conversion can require repeating expansions.

Why is the decimal field text?

Digit strings preserve exact large integers without rounding them through floating-point input parsing.

Sources

Advertisement