Title: For Monday, Aug. 23
1For Monday, Aug. 23
- Review Homework Problems
- A structured way to convert fractions
- Base 16 / 8 / 2hexadecimal, octal, binary
- Addition, Subtraction
- 2s Complement
2Homework for Monday, August 23
- 1) (15 points)
- What decimal number is represented by the
following numbers?A) 10110.1012 ?10 - B) 100110. 1002 ?10
- C) 341.15 ?10
- 2) (15 points)
- What is the base-n representation of the
following decimal numbers? - A) 54.7510 ?2
- B) 123.62510 ?2
- C) 123 ?5
31) (15 points) What decimal number ?
- A) 10110.1012 ?10
- 01 12 14 08 116 1(1/2) 0(1/4)
1(1/8) 22.625 - B) 100111. 1002 ?10
- 11 12 14 08 016 132 1(1/2)
39.5 - C) 341.15 ?10
- 325 45 11 1(1/5) 96.210
42) (15 points)What is the base-n representation?
- Heuristically
- A) 54.7510 ?2
- 54 32 16 4 2 0.75 1/2 1/4 110110.112
- B) 123.62510 ?2
- 123 64 32 16 8 2 1 0.625 1/2 1/8
- 1111011.1012
- C) 123 ?5
- 123 425 45 3 4435
52) (15 points)What is the base-n representation?
- A) 54.7510 ?2 B) 123.62510 ?2 C)123 ?5
- 54/2 27 0 123/261 1 123/524 3
- 27/2 13 1 61/2 30 1 24/5 4 4
- 13/2 6 1 30/2 15 0 4/5 0 4
- 6/2 3 0 15/2 7 1 12310 4435
- 3/2 1 1 7/2 3 1
- 1/2 0 1 3/2 1 1
- 5410 1101102 12310 11110112
6Check your work
- By converting back
- By using another method
1111011.1012 11 12 04 18 116
132 164 1(1/2) 0(1/4) 1(1/8)
123.62510
54 272 027 132 113 62 1 6
32 0 3 12 1 1 02 1 5410
1101102
7A Structured Way to ConvertDecimal to Binary
- Represent a decimal fraction as binary
digits0.y10 0.abcde2 (a,b,c,d,e,f) ?(0,1) - 0.y10 a2-1 b2-2 c2-3 d2-4 e2-5
- Multiply by two
0.y2 a b2-1 c2-2 d2-3 e2-4
an integer a fraction
The first integer after multiplying by 2 is the
most significant bit of the binary representation
of a fraction
8Continued multiplication
- 0.y2 a b2-1 c2-2 d2-3 e2-4
an integer a fraction (call it z)
The second integer after multiplying by 2 is the
coefficient of 2-2 in the binary representation
? Continue multiplying and saving integers
9An Example
- What is the binary representation of 0.0625?
- 0.0625 2 0 .125
- 0.125 2 0 .250
- 0.250 2 0 .500
- 0.500 2 1 .000
Read integers from first to last .062510 .00012
(1/16)
10The result is sometimes a continued fraction
- What is the binary representation of 0.6510?
- 0.65 2 1 .30
- 0.30 2 0 .60
- 0.60 2 1 .20
- 0.20 2 0 .40
- 0.40 2 0 .80
- 0.80 2 1 .60
- 0.60 2 STOP! This would continue forever.
- 0.65 0.101001 (the overbar indicates the
digits to be repeated)
11Octal
- Octal digits relate to powers of 8367.28 3
82 6 81 7 80 2 8-1 3 64 6
8 7 1 2 1/8 192 48 7 2/8
247.25 - To convert from decimal to octal
- Hueristic combine powers of 8
- Structured
- Integer Repeatedly divide by 8 and record the
remainders. The last remainder is the most
significant digit - Fraction Repeatedly multiply by 8 and record the
integers. The first integer is the most
significant digit
12Hexadecimal
- Hexadecimal digits relate to powers of 16367.216
3 162 6 161 7 160 2 16-1 3
256 6 16 7 1 2 1/16 768 96
7 2/16 871.125 - To convert from decimal to Hexadecimal
- Hueristic combine powers of 16
- Structured
- Integer Repeatedly divide by 16 and record the
remainders. The last remainder is the most
significant digit - Fraction Repeatedly multiply by 16 and record the
integers. The first integer is the most
significant digit
13Counting
- Decimal Octal Hexadecimal
- 0 0 0
- 1 1 1
- 2 2 2
- 3 3 3
- 4 4 4
- 5 5 5
- 6 6 6
- 7 7 7
- 8 10 8
- 9 11 9
- 10 12 ?
Decimal Octal Hexadecimal 10 12 A 11 13 B 12 14 C
13 15 D 14 16 E 15 17 F 16 20 10 17 21 11 25 31
19 26 32 1A
14Binary ? Octal Binary ? Hexadecimal
- Each octal digit exactly 3 binary digits
(bits)Each hexadecimal digit exactly 4 bits - Start from the decimal point and work
outward123.62510 1111011.1012 1 111 011 .
101 173.58123.62510 1111011.1012
111 1011 . 1010 7B.A16 - These can be shortcuts to converting decimal ?
binary1111011.1012 173.58 164 78 3
5(1/8) 123.625
123.62510 7B.A16 716 11 10(1/16)
123.625 - To convert from octal ? hexadecimal, use binary
15Addition
- x y CarryIn Sum CarryOut
- 0 0 0 0 0
- 0 0 1 1 0
- 0 1 0 1 0
- 0 1 1 0 1
- 1 0 0 1 0
- 1 0 1 0 1
- 1 1 0 0 1
- 1 1 1 1 1
16Check your work 45 29 74
Carry
1 0 1 1 0 1 0 1 1 1 0 1
1 0
0 1
1 0
1 1
1 0
1 0
1
Sum
17Homework for Wednesday, Aug. 25
- 1. (15 points) Use the structured method to
convert the following decimal number to - a) binary, b) hexadecimal, c) octal
- 114.125
- 2. (10 points) Check your work for problem 1 by
converting the binary equivalent you found in
part a) to hexadecimal and to octal. (Note use
groups of 3 and 4) - 3. Perform the following addition in base 2.
Check your work by converting each addend and the
sum to decimal. - 101011
- 111011