Newbie needing help

Good morning everyone!

I am currently taking a computer programming and problem solving class. I have absolutely no previous programming experience, so I might as well be learning the Japanese language. I am currently working on some beginning exercises, and converting decimal to hex. I have had no problems thus far, but I'm stumped on converting the number 520. I divided 256 into 520 and came up with the answer "2 with a remainder 8". Why, then, is my answer not 2 8? I see the answer is 208. Is it because I need three numbers? We are currently working on int, floats, and char (positive and negative).

I apologize in advance if this is a silly question. Like I said, I'm new to all this, and Math is not my favorite subject!

Joanie
Um... it's really hard to tell what's wrong without knowing what you actually did.
I did mention what I did. I divided 256 into 520. So why is the hexadecimal equivalent 208 and not 2 8?
I think hanst99 means is what you did for the code. After all this is a programming site and not a math site.

But I think I can help.

That's the value for the 162 place not the full answer. then what you do is you multiply 16 by .8 to get your next place value and then you multiply that remainder by 16 and you should get the last place number with a remainder of zero.
Last edited on
Thanks for your help, Hirokachi. I realize this is not a math site. I have no knowledge of programming, but I have to take this class. The professor started us out trying to learn the positive and negative ints, floats, and characters. I got all the answers correct, or so I thought, but in doing the problem like the way he told us to do it, I am not coming up with 208 for the answer. He told us to keep dividing by 16 until the remainder is zero. I know this is minor for most people, but it's really confusing me. Thanks again, and I'm sure I'll be back!
What is with that space? Put a zero there as a placeholder and your answer is right.

Just like in base ten, you have the a value for each digit. The ones digit is X times 100, then tens place is X times 101, and so on.

Similarly, hexadecimal/base sixteen's rightmost digit is X times 160, the next is X times 161, and the next is X times 256, or X times 162 as Hirokachi said. 256 goes into 520 twice, remainder 8 as you calculated. So we know the third digit should be 2. Now we move right to the second; 161 = 16 goes into 8 no times, so that digit should be 0. Finally, 160 = 1 goes into 8 eight times, so the final (rightmost) digit is 8. So we have 208.

Does that make any more sense?
Topic archived. No new replies allowed.