
David W. answered 01/14/17
Tutor
4.7
(90)
Experienced Prof
You are asking about what are called "positional number systems." Each place in the number has an associated value.
So, in decimal, we have ones place, tens place, hundreds place, ... and tenths place, hundredths place, etc.
In hexadecimal, we have ones place, sixteens place, 256s place, ... and sixteenths place, 256ths place, etc. (note: I am referring to these positions in decimal terms for convenience). These positions are often written as powers of the number base.
Now, the following algorithm is useful for converting from decimal to hexadecimal:
Successive multiplication is used to convert a given fractional decimal number to its equivalent hexadecimal fraction.
Here the given decimal fraction is successively multiplied by the base of the target number system (16, here it is hexadecimal system).
Here the given decimal fraction is successively multiplied by the base of the target number system (16, here it is hexadecimal system).
1. During each multiplication iteration, the product generated will have a carry (integer part of the product) and a fractional part.
2. The carry obtained at each multiplication step becomes a numeral in the hexadecimal fraction.
2. The carry obtained at each multiplication step becomes a numeral in the hexadecimal fraction.
3. The fractional part of the product is again multiplied by base 16 in the next step and the process is repeated until the fractional part becomes zero or the number of multiplication iteration equals the number of digits after the decimal point in the given decimal fraction (note: pi keeps going and going and going ...)
4. Weights are assigned for the carry obtained at each multiplication step in the increasing order starting from the first multiplication step to the last step, such that the carry obtained in the first multiplication iteration is the most significant bit (MSD) after the decimal point and the carry obtained in the last multiplication iteration is the least significant bit (LSD)
This procedure is illustrated in the following example.
This procedure is illustrated in the following example.
3.1415926 is 3 + 0.1415926
is 3 with 0.1415926*16
= 3.2 with 0.2654816*16
= 3.24 with 0.2477056*16
= 3.243 with 0.9632896*16
note: be sure to use A-F when appropriate.
In Decimal, pi = 3.141592653589793238462643383279....
In Hexadecimal, pi = 3.243F6A8885A308D313198A2E037073....