#7**+10 **

Hi Chris,

Sir Emo did it the other way around to me, that is how I used to do it too but I learned my new way from Heureka and it is better I think.

2308 base 10

you want to convert it to base 16

Just think for a moment about what the place values will be in base 16

$$16^6\quad 16^5 \quad 16^4 \quad 16^3\quad 16^2\quad 16^1\quad 16^0$$

Now all these places have numbers that are divisable by 16 - except the last one.

SO if we divide 2308 by 16 the remainder will be in the last place. The remainder is 4 so that is the last digit.

Now I divide the rest of the number by 16. This will effectively push all the digits over one place.

Like in base 10 if you divide 60 by 10 you get 6.... see the 6 moved to one smaller place.

2308-4=2304 and 2304 divided by 16 = 144

So now you go through the same process with 144

144/16 = has no remainder so the 2nd smallest digit is 0

144/16=9 9 is smaller than 16 so it will be the 3rd smallest digit.

The number will be 904 base 16

The reason I like this method better is that you do not have to work out in advance how many digits your new number is going to have. So it would be much better if you were converting really big numbers. You just keep going until the division by 16 produces a number that is less than 16.

Melody
Jun 21, 2015

#2**+10 **

If it is in hex and you want to convert it to base 10 then it is

$$2308_{16}=2*16^3+3*16^2+8$$

$${\mathtt{2}}{\mathtt{\,\times\,}}{{\mathtt{16}}}^{{\mathtt{3}}}{\mathtt{\,\small\textbf+\,}}{\mathtt{3}}{\mathtt{\,\times\,}}{{\mathtt{16}}}^{{\mathtt{2}}}{\mathtt{\,\small\textbf+\,}}{\mathtt{8}} = {\mathtt{8\,968}}$$

$$2308_{16}=8968_{10}$$

If it is in base 10 and you want to chang it to base16

$${\mathtt{2\,308}} \,{mod}\, {\mathtt{16}} = {\mathtt{4}}$$ the last digit is 4

$${\frac{{\mathtt{2\,308}}}{{\mathtt{16}}}} = {\frac{{\mathtt{577}}}{{\mathtt{4}}}} = {\mathtt{144.25}}$$

$${\mathtt{144}} \,{mod}\, {\mathtt{16}} = {\mathtt{0}}$$ the second last digit is 0

$${\frac{{\mathtt{144}}}{{\mathtt{16}}}} = {\mathtt{9}}$$ the third last digit is 9

$$2308_{10}=904_{16}$$

check

$${\mathtt{9}}{\mathtt{\,\times\,}}{{\mathtt{16}}}^{{\mathtt{2}}}{\mathtt{\,\small\textbf+\,}}{\mathtt{4}} = {\mathtt{2\,308}}$$

Melody
Jun 21, 2015

#3**+5 **

Melody.....could you explin how that last conversion to base 16 works????........I see what you did, but I can't quite wrap my head around that.....

CPhill
Jun 21, 2015

#4**+10 **

**Converting from denary (base-10) to Hexadecimal (base-16): **

*We need only three values, as the maximum in three hexadecimal is 4096*

*A good check to see how many you need is guess the highest, and see if it can fit. For example if we guessed 3 values, then you can see if 16 ^{3} is large enough to fit it. Now see about 2 values. 16^{2} is easily not big enough so it will take more than 2 values to fit.*

*First we see how many of the first significant value we need...*

*Since the third value is 16 ^{2} = 256, we must check how many of these fit.*

2308 / 256 = **9** [4 remainder]

*Now we see how many we need of the next...*

*With what we got left, let's see how many of the second value we need which are each worth 16. *

4 / 16 = **0** [4 remainder]

*And finally let's see how many of the last value we need. This converts pretty easily. This is technically how many "16 ^{0} = 1"s you can fit into it.*

4 / 1 = **4**

*The result will be:*

**9 0 4**

Sir-Emo-Chappington
Jun 21, 2015

#7**+10 **

Best Answer

Hi Chris,

Sir Emo did it the other way around to me, that is how I used to do it too but I learned my new way from Heureka and it is better I think.

2308 base 10

you want to convert it to base 16

Just think for a moment about what the place values will be in base 16

$$16^6\quad 16^5 \quad 16^4 \quad 16^3\quad 16^2\quad 16^1\quad 16^0$$

Now all these places have numbers that are divisable by 16 - except the last one.

SO if we divide 2308 by 16 the remainder will be in the last place. The remainder is 4 so that is the last digit.

Now I divide the rest of the number by 16. This will effectively push all the digits over one place.

Like in base 10 if you divide 60 by 10 you get 6.... see the 6 moved to one smaller place.

2308-4=2304 and 2304 divided by 16 = 144

So now you go through the same process with 144

144/16 = has no remainder so the 2nd smallest digit is 0

144/16=9 9 is smaller than 16 so it will be the 3rd smallest digit.

The number will be 904 base 16

The reason I like this method better is that you do not have to work out in advance how many digits your new number is going to have. So it would be much better if you were converting really big numbers. You just keep going until the division by 16 produces a number that is less than 16.

Melody
Jun 21, 2015

#9**+5 **

Either way works. Ultimately it comes down to preference which is used.

I am inclined to agree however, your method looks nicer. I personally am more familiar with methods that work with the most significant values first and work downwards, but I can see how your method is better adapted to unknown sizes if you are unfamiliar with hexadecimal scales. (You have also just given me a good idea for something I want to change in a program. Cheers)

Sir-Emo-Chappington
Jun 21, 2015

#10**+5 **

Thanks, guys....I intuitively see Sir-Emo-Chappington's method more easily, but Melody's method provodes a nice "not having to think about it" way to do it as well......I'll have to practice that one....!!!!

CPhill
Jun 21, 2015