Wednesday, November 20, 2013

Exercise 3.2

Exercise 3.2
Hexadecimal (base 16) is also a commonly used numbering system for representing values in computers. In fact, it has become much more popular than octal. The following table shows pairs of hexadecimal numbers.



A
B
a
1446
672F
b
2460
4935

Binary Conversion


A
B
a
0001 0100 0100 0110
0110 0111 0010 1111
b
0010 0100 0110 0000
0100 1001 0011 0101


3.2.1 What is the sum of A and B if they represent unsigned 16-bit hexadecimal numbers? The result should be written in hexadecimal. Show your work.

a)
1446 +
672F
7B75

0001 0100 0100 0110 +
0110 0111 0010 1111
0111 1011 0111 0101

b)
2460 +
4935
6D95

0010 0100 0110 0000 +
0100 1001 0011 0101
0110 1101 1001 0101

3.2.2 What is the sum of A and B if they represent signed 16-bit hexadecimal numbers stored in sign-magnitude format? The result should be written in hexadecimal. Show your work.

In sign magnitude format, the most significant bit is a sign bit.  In order to have a sign bit set in hex, the leading ‘character’ must be 8-F.  In none of the given numbers, or answers, is this the case.  The binary math also supports this. This makes the answers to this problem, the exact same as the one above.



3.2.3 Convert A into a decimal number, assuming it is unsigned. Repeat assuming it stored in sign-magnitude format. Show your work.

See spreadsheet.  As with exercise 3.1, I have made a sheet with weights and sums to represent the long hand math to calculate decimal from binary.
a. 5190
b. 9312




A
B
a
C352
36AE
b
5ED4
07A4

Bit Conversion



A
B
a
1100 0011 0101 0010
0011 0110 1010 1110
b
0101 1110 1101 0100
0000 0111 1010 0100


3.2.4 What is A – B if they represent unsigned 16-bit hexadecimal numbers? The result should be written in hexadecimal.

a.
C352 -
36AE
8CA4

1100 0011 0101 0010 -
0011 0110 1010 1110
1000 1100 1010 0100
   8       C      A      4


b.
5ED4 -
07A4
5730

0101 1110 1101 0100 -
0000 0111 1010 0100
0101 0111 0011 0000
  5       7       3       0

3.2.5 What is A – B if they represent signed 16-bit hexadecimal  numbers stored in sign-magnitude format? The result should be written in hexadecimal.

a.
C352 = 1100 0011 0101 0010
The sign bit is set, so this is a negative number
-A-B = -(A+B)
0100 0011 0101 0010 = 4352

4352 +
36AE
7A00

0100 0011 0101 0010 +
0011 0110 1010 1110
0111 1010 0000 0000
   7      A       0       0

Now we add the sign bit back in

1111 1010 0000 0000
  F       A       0       0

b.
0101 1110 1101 0100 - 0000 0111 1010 0100
neither one have a sign bit set, so the math is same as unsigned math above.

3.2.6 Convert A into a binary number. What makes base 16 (hexadecimal) an attractive numbering system for representing values in computers?

I have been working with binary as i went as an additional proof to the math.


Hex is a very useful numerical system.  It is the primary representation of memory addresses in computers as modern computers operate at a base of 16, my computer, for example, is 64 bit, so 16*4.  This makes representation accurate and easy.  In addition it allows large numbers to be displayed in less digits, for example, Hex Dword(32 bits) is written as FFFFFFFF, just 8 digits, but in decimal is represented as 4294967295, 10 digits.

The largest downside of this representation comes with its verbal representation.  The symbols for decimal 10-15 (A-F) can easily be misinterpreted.  For example, 40 and 4D, have very similar pronunciations.

1 comment: