Big Moose Saloon
 Search | Java FAQ | Recent Topics Register / Login

# Bits Conversion

MI Mohammed
Ranch Hand

Joined: Feb 16, 2005
Posts: 146
Pls can someone help me out, my exam is next weekend
i am waiting 2 much time conveting Hex nos to Binary.
Pls what is the short cut.

SCJA(Beta) SCJP 1.4 SCWCD 1.4 SCBCD 1.3 SCBCD 5.0 beta <br />The more practice we get, the better we are at the exams and in life in general. Pls join me at My DEN.
marc weber
Sheriff

Joined: Aug 31, 2004
Posts: 11343

Each hexadecimal digit represents 4 binary bits, since 2^4 = 16. (Similarly, each octal digit represents 3 binary bits, since 2^3 = 8.)

[ March 30, 2005: Message edited by: marc weber ]

"We're kind of on the level of crossword puzzle writers... And no one ever goes to them and gives them an award." ~Joe Strummer
sscce.org
Mike Gershman
Ranch Hand

Joined: Mar 13, 2004
Posts: 1272
Memorize the following sixteen equations and you will waste no more time converting between hexadecimal and binary.

0 = 0000
1 = 0001
2 = 0010
3 = 0011
4 = 0100
5 = 0101
6 = 0110
7 = 0111
8 = 1000
9 = 1001
10 = 1010
11 = 1011
12 = 1100
13 = 1101
14 = 1110
15 = 1111

You can learn this in under an hour with handwritten flash cards.

You could figure these out each time with powers of 2, but that takes time on your exam. Also, you will find this memorization very useful in your work life.

Mike Gershman
SCJP 1.4, SCWCD in process
ankur rathi
Ranch Hand

Joined: Oct 11, 2004
Posts: 3830
I do it like this :

Suppose hexa decimal number is : fa23

f a 2 3

15 10 2 3

For this you have to remember this table :

15 10 2 3

And now convert them into binary ( 4 digits )

15 => 1111

10 => 1010

2 => 0010

3 => 0011

so the equivalent binary number is : 1111 1010 0010 0011

PS : If have doubt in decimal to binary conversion then feel free to reply back .
marc weber
Sheriff

Joined: Aug 31, 2004
Posts: 11343

I don't know whether this will help, but I draw a table for binary representations. Across the top are powers of 2, and I just place 1's below these (adding the corresponding powers of 2 for the decimal value).

For example, the table below demonstrates 73>>3 = 9 (note that the right bit drops off). Then 9<<1 = 18. And 18>>3 = 2...
shetal bansal
Ranch Hand

Joined: May 09, 2005
Posts: 63
0 = 0000
1 = 0001
2 = 0010
3 = 0011
4 = 0100
5 = 0101
6 = 0110
7 = 0111
8 = 1000
9 = 1001
10 = 1010
11 = 1011
12 = 1100
13 = 1101
14 = 1110
15 = 1111

Instead of summarizing the hex to binary conversion table, one can just write it on a piece of paper using the followin tip and then refer to it whenever the conversion is required.
To get the above table,
Step 1: write 0,1,0,1.. in a column for 16 times.(zero and one alternatively)
Step 2: write 0,0,1,1,0,0,1,1...in the next column towards left 16 times(two times zero, two times one)
Step 3: write 0,0,0,0,1,1,1,1 in the next column towards left 16 times(four time zero, four time one)
Step 4: write 0,0,0,0,0,0,0,0,0,1,1,1,1,1,1,1,1,1 in the next column towards left (it will over the complete 16 time entry, by writtin only once).(eight time zero ,eight time one)
Just put 0,1...15 in front of each row in the above formed column.U can then use it for reference.

Consider Paul's rocket mass heater.

subject: Bits Conversion