Computer Forums

Member Login

Remember Me? Sign Up! | Forgot Password
 
Slogan
 
Computer Forums > Programmers Lounge > Programming Discussions » Was my college book wrong?
Closed Thread
Old 09-06-2006, 07:46 PM   #1 (permalink)
 
True Techie

Join Date: Mar 2006

Posts: 169

Yolkz is on a distinguished road

Send a message via Yahoo to Yolkz
Default Was my college book wrong?

I was reading my homework when it was showing a example of converting binary to hexadecimal...now it says 01100011 you would break into 2 nibbles 0110 and 0011 it says the hexidecimal value of the first nibble would be 6 which I agree with. Then it says the second niblle 0011 would be B which I dont agree with wouldnt it be 3? Becuase 2+1 = 3 not 11 correct?


Sorry if this is the wrong fourm it was kinda tricky to choose a spot to put this.
__________________
<img src=\"http://img406.imageshack.us/img406/6069/starfoxsigwithborderyi0.png\">
Yolkz is offline  
Old 09-06-2006, 08:56 PM   #2 (permalink)
 
Monster Techie

Join Date: May 2004

Location: Tucson, AZ, USA

Posts: 1,183

Vormund

Send a message via AIM to Vormund Send a message via MSN to Vormund Send a message via Yahoo to Vormund
Default

Absolutely--what you said!

You'd think when paying so much for these books...well, I don't know about that one specifically, but in general...:mad:

If you don't mind me asking, what class is this?
__________________
Vormund is offline  
Old 09-06-2006, 09:06 PM   #3 (permalink)
 
True Techie

Join Date: Mar 2006

Posts: 169

Yolkz is on a distinguished road

Send a message via Yahoo to Yolkz
Default

Intro to personal computers. First day of class and we had to read chapter one and I sat there figuring out all the examples to make sure I understood it and I came across that one and was like no theres no way this can be right.
__________________
<img src=\"http://img406.imageshack.us/img406/6069/starfoxsigwithborderyi0.png\">
Yolkz is offline  
Old 09-07-2006, 12:52 PM   #4 (permalink)
 
Super Techie

Join Date: Sep 2005

Posts: 341

hillbillybob

Default

I've never heard of converting an 8 bit binary number to Hex by splitting it to nibbles first. I've always done the entire 8 bits.

First to answer your question, yes, 0110 would be six and 0011 would be 3, which would make your whole byte as 9. However, for both of those nibbles to calculate out that way they would have to be 00000110 and 00000011 in their full byte form, respectively.

How I've always done it -
01100011 is equal to decimal 99.
Now, 16 goes into 99 six even times with three remaining (calculation done in decimal).
16 * 6 = 96 OR 99 / 16 = 6 R 3
Next, we need to convert three decimal to three hex, which is easy.
3(dec) = 3(hex)
our Hex is now $63
01100011 = 99 = $63

for all intents and purposes, you can run this through a calculator. To check many scientific calculators come with the ability to convert number. On windows, calc.exe comes with the ability, just change the view from standard to scientific. Please observe significant digits

Apologies for not having the direct binary to hex conversion process. This method (binary to decimal to hex) has always been the easiest for me.
__________________
The greatest measure of a nation is not it\'s army or economy, but by how many people are trying to get in, and how many people are staying!!
Guns, Guts, and Alcohol made America free.
Born American, Die American
Ubuntu - it\'s all about the bun\'s baby!!!
hillbillybob is offline  
Old 09-07-2006, 01:06 PM   #5 (permalink)
 
Software Developer

Join Date: Mar 2006

Location: Columbus, OH

Posts: 569

jaeusm is on a distinguished road

Default

Quote:
I've never heard of converting an 8 bit binary number to Hex by splitting it to nibbles first.
One hex digit represents four binary digits, which is why some learn this method. It's actually much easier this way.

Quote:
First to answer your question, yes, 0110 would be six and 0011 would be 3, which would make your whole byte as 9.
Intuitively, it seems like you should add the 6 and the 3, but that would yield the wrong answer, as you pointed out. Instead, using this method, you just concatenate the 6 and the 3. Thus, the answer is 63h, which is the same result you calculated.
jaeusm is offline  
Old 09-07-2006, 06:10 PM   #6 (permalink)
 
Super Techie

Join Date: Sep 2005

Posts: 341

hillbillybob

Default

heh, I didn't know that. Thanks for that tip.
__________________
The greatest measure of a nation is not it\'s army or economy, but by how many people are trying to get in, and how many people are staying!!
Guns, Guts, and Alcohol made America free.
Born American, Die American
Ubuntu - it\'s all about the bun\'s baby!!!
hillbillybob is offline  
 
Closed Thread

Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On