IT Log

Record various IT issues and difficulties.

How to convert decimal to hexadecimal


To convert a decimal number to hexadecimal, follow these steps:

  1. Divide by 16: Continuously divide the decimal number by 16.
  2. Record Remainders: Keep track of the remainders from each division. These will form the hexadecimal digits.
  3. Map Remainders to Hexadecimal:
  4. Remainders 0-9 correspond directly to 0-9 in hex.
  5. Remainders 10-15 are represented by letters A-F respectively.
  6. Build the Result: The remainders, read from last to first, form the hexadecimal number.

Example: Convert decimal 258 to hexadecimal.
– 258 ÷ 16 = 16 remainder 2
– 16 ÷ 16 = 1 remainder 0
– 1 ÷ 16 = 0 remainder 1
Reading remainders from last to first gives 102 in hex.

This method efficiently converts any decimal integer to its hexadecimal equivalent.


, , , ,