Exercise 2 - Convert all decimal numbers to binary. Show work.
Remember, 110112 = 2510.
To check your answers in this section, this website is quite useful.
Radix conversion can be done via either the subtraction or division remainder method.
The division remainder method I believe is simpler and faster. Between the two, I recommend using that one.
The following follow shows how to convert via subtraction on the left side and via division remainder on the right:
Note, the final answer is 45810 = 1110010102. The first 1 in the subtraction answer is somewhat cut off in the photo.
Answers:
a) 45810 = 1110010102
b) 67710 = 10101001012
c) 151810 = 101111011102
d) 44012 = 10001001100012
Exercise 8
Same as exercise 2 but now with decimal numbers.
Unlike integer values, fractions do not necessarily have exact representations under all radices.
For matching values that come after the decimal, we can make use of the following:
- 2-1 = (1/2)1 = 1/2 = 0.5
- 2-2 = (1/2)2 = 1/4 = 0.25
- 2-3 = (1/2)3 = 1/8 = 0.125
- 2-4 = (1/2)4 = 1/16 = 0.0625
For conversion, we can either use the subtraction method or the easy multiplication method.
The subtraction method is similar to what we did in exercise 2. Instead of subctracting positive powers of the target radix, we subtract negative powers of the radix.
On the left, we convert 25.8437510 to 11001.110112 via only subtraction. On the right side, we find the values after the decimal via multiplication instead of subtraction.
For the easy multiplication method, simply keep going until we reach 0 or to however decimal places you want (for exercise 8, we stop after 6 even if we can keep going).
For the whole number portion of the radix conversion, use whatever you want. It doesn't have to be subtraction! You could use division instead for the value before the decimal point.
Answers:
a) 25.8437510 = 11001.110112
b) 57.5510 = 111001.1000112 (keeps going but stopping 6 places to the right of the binary point)
c) 80.9062510 = 1010000.111012
d) 327.7812510 = 101000111.110012
Exercise 10
Convert the given binary fractions to decimal. It's actually very simple. Observe the following:
16 | 8 | 4 | 2 | 1 | 0.5 | 0.25 | 0.125 | 0.0625 |
---|---|---|---|---|---|---|---|---|
1 | 0 | 1 | 1 | 1 | 1 | 1 | 0 | 1 |
All you have to do is add up all of the corresponding base-10 numbers with the 'on' bits of the binary fraction.
So then, 10111.11012 = 23.812510
Answers:
a) 10111.11012 = 23.812510
b) 100011.100112 = 35.5937510
c) 1010011.100012 = 83.5312510
d) 11000010.1112 = 194.87510
Exercise 15
We only have to do one of the two hex words from the problem.
Convert either the hexadecimal number DEAD16 or BEEF16 to binary.
To begin, we use hexadecimal because binary can be quite unruly to read so hexadecimal cuts down on the number of digits we need to represent the same number. The same could be said about base-10 though so why hexadecimal? The reason is because it's easy to convert between base-2 and base-16 for 16 = 24.
Also, counting from 0 to 15 in hexadecimal goes like this: 0, 1, 2, 3, 4, 5, 6, 7, 8, 9, A, B, C, D, E , F
Anyways, to convert from binary to hexadecimal, we only need to group the binary digits into groups of four!
So then,
00112 = 316
01012 = 516
00012 = 116
10112 = B16
Answers:
DEAD16 = 1101 1110 1010 11012
BEEF16 = 1011 1110 1110 11112
Exercise 18
This question is a little extra. We are given four base-10 values and have to represent them in 8-bit signed magnitude, one's complement, two's complement, and excess-127 representations. Let's begin by discussing how to do each one.
Firstly, why do we need these representations in the first place? Because we need a way to represent signed binary integers (aka, positive and negative binary integers).
8-bit signed magnitude
For this representation, we have 8 bits. The left most bit is the sign bit. If 0, then we have a positive number. If 1, then it's negative. The rest of the 7 bits are the absolute value of the number in question.
000000112 = +3
100000112 = -3
This sounds pretty great so why do we need the other representations? Well, it might be easy for us humans but no so for computers. It requires complicated computer hardware. Also, we can represent 0 as positive or negative! That isn't very good... As such, we have the complement systems.
One's complement
In complement systems, negative values are represented by some difference between a number and its base.
As with 8-bit signed magnitude, negative values are indicated by a 1 in the high order bit in one's complement.
000000112 = +3
111111002 = -3
Complement systems are great because we no longer need to subtract! The difference between two values is found by just adding.
Two's complement
One's comlement may be simpler to implement than signed magnitude but it still has the disadvantage of having two different representations for zero: positive and negative. Two's complement solves this issue!
If the number is positive, just convert it to binary and you're done! Otherwise, if the number is negative, find the one's complement of the number then add 1.
000000112 = +3
111111012 = -3 (notice that -3 in one's complement is just this but subtract 1)
Excess-M Representation (also known as offset binary representation)
So then, just what in the world is excess-127 representation? Well, excess-m representation is another way for unsigned binary values to represent signed integers. It is intuitive for a binary string with all 0s represents the smallest number, whereas the binary string with all 1s represent the largest value. An unsigned binary integer M (called the bias) represents the value 0, whereas all zeroes in the bit pattern represent the integer -M.
The integer is interpreted as positive or negative depending on where it falls in the range.
The unsigned binary value for a signed integer using excess-M representation is determined simply by adding M to that integer.
For example, assuming excess-7 representation, the integer 010 is represented as 0 + 7 = 710 = 01112
310 is represented as 3 + 7 = 1010 = 10102
-710 is represented as -7 + 7 = 010 = 00002
What if we want to find the decimal value of the exess-7 binary number 11112? Subtract 7 from 11112 = 1510 and 15 - 7 = 8 thus 11112 in excess-7 is +810.
Answers:
a) 97
Signed Magnitude: 01100001
One's Complement: 01100001
Two's Complement: 01100001
Excess-127: 97 + 127 = 22410 = 111000002
b) -97
Signed Magnitude: 11100001
One's Complement: 10011110
Two's Complement: 10011111
Excess-127: -97 + 127 = 3010 = 000111102
c) 44
Signed Magnitude: 00101100
One's Complement: 00101100
Two's Complement: 00101100
Excess-127: 44 + 127 = 17110 = 101010112
d) -44
Signed Magnitude: 10101100
One's Complement: 11010011
Two's Complement: 11010100
Excess-127: -44 + 127 = 17110 = 010100112
Exercise 20
What decimal value does the 8-bit binary number 10011110 have if the following:
Answers:
a) It is interpreted as an unsigned number? 15810
b) Signed magnitude? -30
c) One's complement? -97
d) Two's complement? -98
e) Excess-127? -157
I double checked and not sure why I thought it was -157. The answer should be 31.
To find the decimal value of the excess-127 binary number 100111102, we must subtract 127. So, 1001111012 = 15810. Subtract 127 from 158 so 158 - 127 = 31.
Exercise 33
Adding unsigned binary numbers. Very simple. There are no complicated rules normally associated with adding binary numbers from other representations. Literally just add as you normally would while carrying. Remember, 1 + 1 = 10
Answers:
a) 11111111
b) 01111010
c) 11010000
Exercise 35
He had us skip this question so I won't bother with it.