Forum Home
Press F1
 
Thread ID: 50861 2004-11-03 22:59:00 Really having difficulty converting decimal to hexadecimal yingxuan (3330) Press F1
Post ID Timestamp Content User
287669 2004-11-03 22:59:00 hello
I am stuck on a question

I have the number 2947 and need to convert to hexadecimal.
As far as I'm aware u divide 2947 by 16 as hexadecimal base is 16.

but as I keep dividng I notice that what I thought I am doing is wrong.
Could anybody please help me?
yingxuan (3330)
287670 2004-11-03 23:06:00 0123456789abcdef

2947 = 00000B83

Cheers Murray P
Murray P (44)
287671 2004-11-03 23:06:00 If u use XP its calculator if u view scientific will give u the answer.

B83 according to XP's calculator is 2947 Dec in HEX.
Spacemannz (808)
287672 2004-11-03 23:07:00 Yeah I know but I wanna know the logic behind it.Working on how to actually get that answer yingxuan (3330)
287673 2004-11-03 23:13:00 Readme (www.danbbs.dk) ;)

Cheers Murray P
Murray P (44)
287674 2004-11-03 23:17:00 Ah thanks.!!i wanted to find a simple instruction page to work with! yingxuan (3330)
287675 2004-11-03 23:34:00 44978 /16= 2811

remainder is 2.
From that site below.Decimal to hexadecimal conversion.u divide the number by 16.

in this case 44978/ 16 is 2811

Why is the remainder 2?
yingxuan (3330)
287676 2004-11-04 00:46:00 The remainder is 2 because that's what left over when you do that division. :D 2811*16 --> 44976. 44978-44976-->2.

But.

You shouldn't be dividing 44978 by 16. You need to start with the biggest power of 16 which will fit. (I suspect the tutorial might have dealt only with small numbers. :_|

Decimal numbers have one column for each power of 10 : 10^0, 10^1, 10^2, 10^3 ... (from right to left).

Hex numbers use one column for each power of 16: 16^0, 16^1, 16^2, 16^3 ... (again from right to left).

the powers of 16 are: 1, 16, 256, 4096, 65536, ...

To convert 44986: 65536 is too big, so try 4096. That gives 10 (decimal !) so write down "A" in the first column. The remainder is 4026, so divide that by 256, make the answer into hex, and write that down. You have a remainder, again, so divide that by 16 for the penultimate digit. The remainder is less than 16 (by definition) so that's the last column.
Graham L (2)
287677 2004-11-04 01:25:00 Thanks for that.My friend looked at it and explained what you just wrote to me! yingxuan (3330)
287678 2004-11-04 01:29:00 And remember that if you skip a "powerof16", you neet to put a "0" in that column. Graham L (2)
1 2