Converting Decimal Number Into Hexadecimal Number in Visual C
Converting Decimal Number Into Hexadecimal Number in Visual C
The following method will convert positive integer in the range of 0-2^16 to hexadecimal
number.
Method will start to divide argument ‘Input’ by 2^15 and convert the integer part of the
quotient to a hexadecimal digit. Then, the product of quotient and 2^15 will be subtracted
from ‘Input’ and difference will be used as new dividend to be divided in 2^14 and so on…
When a first non-zero digit will be detected, variable ‘start’ will turn to TRUE and
hexadecimal digits will be accumulated. Thus, leading zeroes will not be displayed.
Method will utilize additional method DigitLetter that will obtain integer between 0-15
and return its hexadecimal value: