1.

Solve : Converting Binary Numbers to Decimals and Converting Hexadecimals?

Answer»

Hello,

I was reading through CompTIA A+ for Dummies I came to a SECTION about reading binary numbers and converting them into decimal values and then about converting hexadecimal. I didn't find the examples and the explanation to be very helpful. Is there someone that can explain this in a better way then the book.

Thank youCould you post a couple of the examples that you are having a hard time with?
The more information that you provide will allow the support to be far more accurate.The book states:

You may see a question on the test asking you to convert a binary number such as 00000101 to a decimal value—you know, ordinary numbers. The key is to remember that each position REPRESENTS a power of 2, starting with 0 on the right end up through 7 at the left end. For example, the binary number 00001010 contains
0 ¥ 20 = 0 (any number to the zero power is worth 1)
1 ¥ 21 = 2 (any number to the one power is the number)
0 ¥ 22 = 0 (two times two)
1 ¥ 23 = 8 (two times two times two)
Totaling 10 (the remaining positions are all zero)

http://imageshack.us/f/836/acefquestions.jpg/

This one looks at hexadecimal numbers.

http://imageshack.us/f/717/acefquestions2.jpg/


This link shows the questions the book  was asking. I was wondering  if someone took take a look at this and walk me though how to do this.

Thank youI thought I understood this stuff pretty well, but I have to admit that those pages confused me. Maybe it's just the wording.

I hope this is helpful for you.

Working with Number Bases:
http://mathbits.com/mathbits/compsci/introduction/Nbases.htm

Converting from base 10:
http://mathbits.com/mathbits/compsci/introduction/frombase10.htm


Converting to base 10:
http://mathbits.com/mathbits/compsci/introduction/tobase10.htm

Converting via base 10:
http://mathbits.com/mathbits/compsci/introduction/viabase10.htm


Another thing which might prove useful is this way to convert binary to hex and back again. One hex character is USED to represent four binary characters. Here is the key:

0000 = 0

0001 = 1

0010 = 2

0011 = 3

0100 = 4

0101 = 5

0110 = 6

0111 = 7

1000 = 8

1001 = 9

1010 = A

1011 = B

1100 = C

1101 = D

1110 = E

1111 = F

If you can keep these in mind you can quickly convert between binary and hexadecimal. Memorize the sequence of the numbers zero to eight.
0000
0001
0010
0011
0100
0101
0110
0111
1000
Once you have that in you brain, you can figure how to finish the sequence up to fifteen. That is the key of converting from Hexadecimal and bainary.
For decimal, memorize this decimal sequence.
128 64 32 16 8 4 2 1
Those above are the values of the lower eight bits.
Then memorize :
16384 8192 4096 2048 1024 512 256
Those are for the upper eight bits.

So a binary number such as: 
0000-0100 0000-0001
is 1024 + 1 = 1025
With a little practice...

Study the numbers and you will catch on.
Noways it is MUCH easier that it used to be -
when they had the other kind of binary numbers.Maybe this can help, number is what it will display in binary but its easy enough to modify for other purposes.

//this is the number to be shown in binary
int number = 10;

vector bin;

//this loop is the length of the binary string so if showing binary of 1 it will show 0 0 0 0 0 0 0 0 0 1
    for (int i = 10; i >= 0; i--){
        int bit = ((number>> i) & 1);
        bin.push_back(bit);
   }//for

   for (int i = 0; i < bin.size(); i++)
      COUT << bin.at(i) << " ";

   cout << endl;In the event that you ever have to do binary decimals (or bimals!):

The first place after the decimal represents 1/2 (10.1 = 2.5)
The 2nd place is 1/4 (110.11=6.75)
and so on, keep dividing by 2

Hexadecimal works the same way, 0.F = 15/16; 0.1 = 1/16; 0.8 = 1/2



Discussion

No Comment Found