=================================================
Notes and answers for Lab 03 (binary conversions)
=================================================
- Ian! D. Allen - idallen@idallen.ca - www.idallen.com
Reference: lab03.pdf
The point of the binary-decimal conversions in Lab 3 is not to show me the
answer. I already gave you the answer. The point is to show me that
you have a clear *method* for getting that answer that works for you.
You must show me a clear method that turns the decimal into binary.
The method must work for any unsigned decimal number (or fraction).
The point of the binary-decimal conversions in Lab 3 is not to show me
that you can convert the binary back to decimal by adding up powers of
two in the answer. Your tests and exams won't have any answers. You will
need a method for converting decimal to binary. Show me your method.
Calculators are not permitted during the tests and exams. You will
benefit from knowing the powers of two from 2**0 to 2**16. Of course
you can work them out; however, having at least some of them memorized
will make things go faster for you.
You will also benefit from knowing the bit patterns for the sixteen
hexadecimal digits from 0,...,9,A,...,F Of course you can work them
out; however, having at least some of them memorized will make things
go faster for you.
Practice:
Write down any three-digit decimal number (e.g. 314).
Convert it to binary using your method.
Check your work on the Internet, using a decimal-to-binary
conversion web page. Google search: decimal to binary conversion
Sample conversion site:
http://acc6.its.brooklyn.cuny.edu/~gurwitz/core5/nav2tool.html
Quiz site:
http://acc6.its.brooklyn.cuny.edu/~gurwitz/core5/binquiz.html
Subtraction method:
http://www.is.wayne.edu/olmt/binary/page3.htm
Answers to CST8214 Lab Three - Sep 24, 2007
-------------------------------------------
1. 1 2 4 8 16 32 64 128 256 512 1024 2048 4096 8192 16384 32768 65536
2. 25 --> 11001
take 1 x 16 from 25 leaving 9 <-- leftmost bit of answer in here
take 1 x 8 from 9 leaving 1
take 0 x 4 from 1 leaving 1
take 0 x 2 from 1 leaving 1
take 1 x 1 from 1 leaving 0 <-- rightmost bit of answer in here
OR:
25 div by 2 is 12 rem 1 <-- rightmost bit of answer
12 div by 2 is 6 rem 0
6 div by 2 is 3 rem 0
3 div by 2 is 1 rem 1
1 div by 2 is 0 rem 1 <-- leftmost bit of answer
3. 147 --> 10010011
take 1 x 128 from 147 leaving 19 <-- leftmost bit of answer in here
take 0 x 64 from 19 leaving 19
take 0 x 32 from 19 leaving 19
take 1 x 16 from 19 leaving 3
take 0 x 8 from 3 leaving 3
take 0 x 4 from 3 leaving 3
take 1 x 2 from 3 leaving 1
take 1 x 1 from 1 leaving 0 <-- rightmost bit of answer in here
OR
147 div by 2 is 73 rem 1 <-- rightmost bit of answer
73 div by 2 is 36 rem 1
36 div by 2 is 18 rem 0
18 div by 2 is 9 rem 0
9 div by 2 is 4 rem 1
4 div by 2 is 2 rem 0
2 div by 2 is 1 rem 0
1 div by 2 is 0 rem 1 <-- leftmost bit of answer
4. 0.75 --> 0.11
take 1 x 0.5 from 0.75 leaving 0.25 <-- leftmost bit of answer in here
take 1 x 0.25 from 0.25 leaving 0 <-- rightmost bit of answer in here
OR
0.75 times 2 is 1 plus 0.5 <-- leftmost bit of answer
0.5 times 2 is 1 plus 0.0 <-- rightmost bit of answer
5. 0.8125 --> 0.1101
take 1 x 0.5 from 0.8125 leaving 0.3125 <-- leftmost bit
take 1 x 0.25 from 0.3125 leaving 0.0625
take 0 x 0.125 from 0.0625 leaving 0.0625
take 1 x 0.0625 from 0.0625 leaving 0.0 <-- rightmost bit
OR
0.8125 times 2 is 1 plus 0.625 <-- leftmost bit of answer
0.625 times 2 is 1 plus 0.25
0.25 times 2 is 0 plus 0.5
0.5 times 2 is 1 plus 0 <-- rightmost bit of answer
6. 0000 0001 0010 0011 ... 0111 1000 ... 1100 1101 1110 1111
0h 1h 2h 3h ... 7h 8h ... Ch Dh Eh Fh
0 1 2 3 ... 7 8 ... 12 13 14 15
7. 110 011 101 010 100 001 111 000
6 3 5 2 4 1 7 0 octal (group from right by 3 bits)
8. 1110 1101 0011 1001 1100 0000 0001 1010
E D 3 9 C 0 1 A hex (group from right by 4 bits)
9. 0101 1000 0100 1011 1111 0010 0111 0110
5 8 4 B F 2 7 6 hex (group from right by 4 bits)