My Math Forum  

Go Back   My Math Forum > Science Forums > Computer Science

Computer Science Computer Science Forum


Reply
 
LinkBack Thread Tools Display Modes
March 21st, 2012, 09:25 PM   #1
Igo
Newbie
 
Joined: Jan 2012

Posts: 15
Thanks: 0

Binary to hexadecimal

I know that 1011110000000011 will be BC03

but how do you solve when there are less or more numbers?

for example: 1111000011 and 1110110000110


thanks
Igo is offline  
 
March 21st, 2012, 09:46 PM   #2
Member
 
Joined: Jul 2010

Posts: 83
Thanks: 2

Re: Binary to hexadecimal

Quote:
Originally Posted by Igo
I know that 1011110000000011 will be BC03

but how do you solve when there are less or more numbers?

for example: 1111000011 and 1110110000110


thanks
Basically, one hex digit corresponds to 4 binary digits (a "nibble"), so we can simply extract each successive group of binary digits and map them directly to hex (since they're relatively "friendly" bases). For example, you could just repeatedly perform a logical-and with 0xf and then shift right 4 places until the value reaches zero. A lookup table might be useful, too.
Sebastian Garth is offline  
March 21st, 2012, 09:52 PM   #3
Global Moderator
 
CRGreathouse's Avatar
 
Joined: Nov 2006
From: UTC -5

Posts: 16,046
Thanks: 938

Math Focus: Number theory, computational mathematics, combinatorics, FOM, symbolic logic, TCS, algorithms
Re: Binary to hexadecimal

Quote:
Originally Posted by Igo
but how do you solve when there are less or more numbers?
You can add as many 0s as you need on the left. Just like 23 = 023 in decimal, 1110110000110 = 0001110110000110 in binary.
CRGreathouse is offline  
September 7th, 2012, 04:58 AM   #4
Newbie
 
Joined: Sep 2012

Posts: 7
Thanks: 0

Re: Binary to hexadecimal

Binary to Hex

In the previous screens you converted a Hexadecimal number to Binary by expressing each Hex place as a Binary "quartet" (ie 4-bits). The process of converting from Binary to Hex uses the same 'quartet' approach, but in reverse.
Example 1. Consider Binary: 1000100100110111 (a 16-bit Byte)

STEP 1 Break the Byte into 'quartets' - 1000 1001 0011 0111

STEP 2 Use the table above to covert each quartet to its Hex equivalent - 8937

Therefore ... 1000100100110111 = 8937Hex
richardshelton is offline  
Reply

  My Math Forum > Science Forums > Computer Science

Tags
binary, hexadecimal



Thread Tools
Display Modes


Similar Threads
Thread Thread Starter Forum Replies Last Post
Signed hexadecimal computation! eChung00 Computer Science 3 March 4th, 2013 03:59 PM
Ways of STRAIGHTLY converting hexadecimal to octal & inverse sciencexboy Number Theory 3 October 1st, 2011 09:32 AM
Hexadecimal Addition... Primalscientist Computer Science 13 April 20th, 2011 01:41 PM
Hexadecimal Notation Primalscientist Computer Science 3 April 17th, 2011 04:31 AM
I need some help on binary, hexadecimal and decimal numbers! johnny Computer Science 2 October 13th, 2007 03:00 PM





Copyright © 2019 My Math Forum. All rights reserved.