Skip to content
Conversion

Decimal to Hexadecimal Converter

Enter any whole number below and this converter returns its hexadecimal (base 16) equivalent in uppercase notation, along with the binary (base 2) and octal (base 8) representations. The step-by-step panel shows every division-by-16 iteration so you can follow the math. Negative integers are shown with a minus sign prefix; fractional parts are truncated to the integer portion.

Your details

Enter any whole number (positive or negative). Decimals are truncated to the integer part.
Choose how to format the hex output. Plain, 0x-prefixed (programming), or #-prefixed (CSS/HTML colors).
Hexadecimal
FF

Base-16 representation of the decimal number

Binary11111111
Octal377
Hex digit count2
Binary bit count8

255 decimal = FF hexadecimal

  • 255 in decimal is FF in hexadecimal.
  • It requires 2 hex digits and 8 bits in binary.
  • 255 (0xFF) is the maximum value of an 8-bit unsigned byte, commonly used in RGB color channels.

Next stepIn programming, hex values are commonly prefixed with 0x (e.g., 0xFF). In CSS and HTML colors, the # prefix is used (e.g., #FF6347 for tomato red).

What is hexadecimal?

Hexadecimal is a base-16 number system that uses sixteen distinct symbols: the digits 0-9 for values zero through nine, and the letters A, B, C, D, E, and F for values ten through fifteen. Because 16 = 2^4, each hex digit maps exactly to four binary bits, making hexadecimal a compact, human-readable shorthand for binary data. Computer scientists and programmers use hex constantly: memory addresses, color codes, character encoding, and machine instructions are all routinely expressed in hexadecimal.

How to convert decimal to hexadecimal

The standard method is repeated division by 16. Divide the decimal number by 16, record the remainder (0-15, written as 0-9 or A-F), then divide the quotient by 16 again. Repeat until the quotient reaches zero. Reading the remainders from last to first gives the hexadecimal result. For example, converting 255: 255 / 16 = 15 remainder 15 (F); 15 / 16 = 0 remainder 15 (F). Reading bottom-to-top gives FF. The step-by-step panel above works through every division for your chosen number.

Hex in programming and web design

In most programming languages (C, C++, Java, JavaScript, Python, and many others), hexadecimal literals are written with a 0x prefix, for example 0xFF for 255. In CSS and HTML, colors are specified as #RRGGBB where each pair of hex digits represents the red, green, and blue intensity from 00 (none) to FF (full). A common 8-bit unsigned byte ranges from 0x00 to 0xFF (decimal 0-255). A 32-bit unsigned integer spans 0x00000000 to 0xFFFFFFFF (decimal 0-4,294,967,295). This converter lets you choose between plain hex, 0x-prefixed, or #-prefixed output to match the format your use-case requires.

Decimal, binary, octal, and hexadecimal together

All four common numeral bases relate to each other through powers of 2. Binary (base 2) is the native language of digital hardware; octal (base 8) groups binary digits in threes and was widely used in older Unix systems; hexadecimal (base 16) groups binary digits in fours and is the dominant shorthand used today. A single hex digit represents exactly 4 bits, so a byte (8 bits) is always two hex digits (00-FF), a 16-bit word is four hex digits (0000-FFFF), and a 32-bit double-word is eight hex digits. This neat alignment is why hex, not octal, became the standard for memory dumps and color codes.

Decimal to hexadecimal reference chart (0-30)

DecimalHexBinaryOctal
0000
1111
22102
33113
441004
551015
661106
771117
88100010
99100111
10A101012
11B101113
12C110014
13D110115
14E111016
15F111117
16101000020
17111000121
18121001022
19131001123
20141010024
25191100131
301E1111036
322010000040
402810100050
503211001062
64401000000100
100641100100144
1288010000000200
200C811001000310
255FF11111111377
256100100000000400
10003E811111010001750
65535FFFF1111111111111111177777

Quick-reference values for the first 31 decimal integers and selected larger values.

Frequently asked questions

What is the hexadecimal equivalent of decimal 255?

Decimal 255 is FF in hexadecimal. This is the maximum value of an 8-bit unsigned byte. Each F represents the decimal value 15 (binary 1111), so FF = 15 x 16 + 15 = 255. It is also 0xFF in C-style notation and #FF as a two-digit color component in CSS.

How do I convert a large decimal number to hex by hand?

Use repeated division by 16. Divide the number by 16, write down the remainder (converting 10-15 to A-F), then divide the quotient by 16 again. Keep going until the quotient is 0. Read the remainders from bottom to top. For example, 1000 / 16 = 62 remainder 8; 62 / 16 = 3 remainder 14 (E); 3 / 16 = 0 remainder 3. Reading upward: 3E8. So 1000 decimal = 3E8 hex.

What does the 0x prefix mean in hexadecimal?

The 0x prefix is a programming convention that tells the compiler or interpreter the following characters are a hexadecimal literal, not a decimal number. It originated in the C programming language and is now standard in C++, Java, JavaScript, Python, and most other languages. For example, 0xFF and 255 represent the same value; the 0x prefix just signals the base. In CSS and HTML colors, the # symbol serves the same purpose (e.g., #FF0000 for red).

Can this converter handle negative decimal numbers?

Yes. Negative numbers are converted by taking the absolute value, converting it to hex, and prepending a minus sign. This is the signed-magnitude representation. Note that in low-level programming, negative integers are often represented differently (typically in two's complement), where for example -1 in an 8-bit register is 0xFF. If you need two's complement hex, take the positive magnitude, subtract it from 2^n (where n is your bit width), and convert the result.

Why are only 16 symbols used in hexadecimal?

Hexadecimal is base 16, meaning each position in the number represents a power of 16. You need exactly 16 symbols, one for each value from 0 to 15, to fill every digit position. The digits 0-9 cover values zero through nine, and the letters A through F cover values ten through fifteen. This system maps perfectly onto four binary digits (nibbles), making it far more compact than writing out binary while still being straightforwardly convertible to and from the binary that computers use internally.

How is hexadecimal used in color codes?

Web and graphic design represent colors as six-digit hex codes in the format #RRGGBB. The first two digits are the red intensity (00-FF), the middle two are green, and the last two are blue. For example, #FF0000 is pure red, #00FF00 is pure green, #0000FF is pure blue, and #FFFFFF is white (all channels at maximum). Each pair of hex digits corresponds to a decimal value from 0 (no intensity) to 255 (full intensity), giving 256 levels per channel and over 16 million colors in total.

Sources

Written by Dr. Nadia Petrov, PhD Physicist & Metrologist · Geneva, Switzerland

Bridging fundamental metrology and everyday measurement so every conversion carries the precision its context demands.

Search 3,500+ calculators

Loading search…