1. Home
  2. Developer tools
  3. Decimal to Hex

Decimal to Hex

Enter decimal values and get hexadecimal, together with the remainders from dividing by 16 so you can follow or check the method. Large values are exact, not rounded to floating point.

Free, no sign-up. Runs in your browser: nothing is uploaded.

How to use Decimal to Hex

  1. Enter decimal numbers, one per line.
  2. Read the hex value and the division table.
  3. Pick upper or lower case, and add a 0x prefix if you need one.

Features

  • Division-by-16 table with remainders written as hex digits
  • Exact for integers of any size, including above 2^53
  • Negative numbers show a sign, not a two’s complement pattern
  • Decimal fractions convert with a rounding marker
  • Upper or lower case with optional 0x
  • Many values at once

Supported formats

Input

  • Typed or pasted numbers

You get

  • Hexadecimal
  • Division table

Private by design

Everything you enter is processed by your browser on this device. Nothing is sent to openWorkstand or anyone else, so the Decimal to Hex is safe for private and work data. After you have used it once while online, it also works without an internet connection. How local processing works

Good to know

  • Fractions that do not end in the target base are cut after 24 digits and marked with an ellipsis.
  • Negative numbers are shown with a minus sign; use the two’s complement calculator for the bytes a computer stores.

Guide

Converting decimal numbers to hexadecimal

Decimal is what you type into a form; hexadecimal is what you meet in a CSS file, a port table, a packet capture or a crash report. Moving between them by hand means a short run of divisions, and this page prints each one so you can use it either as a shortcut or as a worked answer.

The method

Divide the number by 16. The remainder is a digit from 0 to 15, written as 0–9 and then A to F. Divide the quotient by 16 again and keep going until the quotient is zero. Read the remainders from the last to the first. Each step removes the least significant hex digit, in the same way that dividing by ten removes the last decimal digit.

Where the result is used

Colour channels run from 0 to 255, which is 00 to FF. TCP and UDP port numbers are often listed in hex in documentation. Unicode code points, error codes from operating systems and offsets in file formats are conventionally written in hex. A programmer who can move between the two quickly spots patterns, such as 65,535 being FFFF, that are invisible in decimal.

Options

Letters can be upper-case, the style of most specifications, or lower-case, the style of many web and Unix tools. The “Add 0x prefix” switch writes the C-style marker in front. “Group digits” splits long results into blocks. Several numbers can be pasted at once, one per line, and every line is converted; the step-by-step working explains the first line.

Edge cases

Single-digit results carry no leading zero, so 10 gives A. If you need two digits for a byte, pad it. Decimal fractions are possible: 255.5 becomes FF.8, because half is 8/16. Many fractions never end, such as 0.1, and are cut off after 24 digits with an ellipsis to show it.

Negative numbers are written with a minus sign: −255 is −FF. A processor would store it differently, usually as a two’s complement bit pattern, so use that calculator when a fixed-width pattern is what you need.

A worked example

The Sample button loads 2026. Dividing gives 2026 ÷ 16 = 126 remainder 10 (A), then 126 ÷ 16 = 7 remainder 14 (E), then 7 ÷ 16 = 0 remainder 7. The remainders read from the bottom are 7, E, A, so the answer is 7EA. To check it, work forward: 7 × 256 is 1,792, E (14) × 16 is 224, and A (10) adds 10; the total is 2,026. The box below also gives binary 11111101010 and octal 3752.

Limits

The page does the arithmetic and nothing more. It does not format colours, add alpha channels or pad to byte boundaries. It also does not know about integer sizes, so a value too big for a 32-bit variable converts without a warning; if the size matters, compare the answer against your type’s range yourself or use the two’s complement calculator, which reports the range.

Checked against the current version of the Decimal to Hex on .

Frequently asked questions

How do I turn an RGB value such as 200 into the two-digit hex used in CSS?

Convert each channel separately. 200 divided by 16 is 12 remainder 8, so the digits are C and 8, giving C8. If the result has only one digit, put a zero in front so each channel has exactly two.

Why do memory addresses and error codes appear in hex instead of decimal?

Because hex lines up with bytes: two digits are always one byte. A 32-bit address is eight digits, and masks and offsets stay aligned, which does not happen with decimal.

Why is 255 written FF?

255 = 15 × 16 + 15, and the digit for 15 is F. So the remainders 15 and 15 give FF.

Will a negative number give FFFF-style output?

No. -1 is shown as -1 in hex. To get the 8-, 16- or 32-bit pattern that a computer stores, use the Two’s Complement Calculator.

Keep working with the result

openWorkstand also includes a free workspace with documents, spreadsheets, tasks, projects and a calendar that save to a folder on your computer.