12.07.2015 Views

williams-et-al-1983-apple-ii-computer-graphics

williams-et-al-1983-apple-ii-computer-graphics

williams-et-al-1983-apple-ii-computer-graphics

SHOW MORE
SHOW LESS
  • No tags were found...

Create successful ePaper yourself

Turn your PDF publications into a flip-book with our unique Google optimized e-Paper software.

APPENDIX 1-DECIMAL, HEX, AND BINARY 171the only available digits, and that a binary two is written as 1([), and binarythree is 11. Why are those important? We will demonstrate by adding!©©1 1 ©1 1 © to !©©©1 11([)1.-1'1 1 1! 001 1 01 10+ ! 0001 1101! 0101 001 1Figure A 1-4.Beginning at the right side, the fi rst column is © + 1 which gives you 1.You should <strong>al</strong>so g<strong>et</strong> a one in the second column without too muchtrouble-so far, so good. The third column g<strong>et</strong>s more complex as you have1 + 1. Any norm<strong>al</strong> second-grader can tell you that 1 + 1 = 2, butprogrammers should make no pr<strong>et</strong>ense at norm<strong>al</strong>cy. As we mentionedabove, two is written as 1([) (one-zero, not ten!), which puts the zero in theanswer and carries the one to the next column. Including the carry, thatnext column now requires you to add 1 + © + 1, which again gives 1©(write down the zero and carry the one) . The one is carried over to thefifth column where you now have 1 + 1 + 1 which yields three (1 1). Forthat, you must write down a one and carry a one to the next columnwhich then looks like 1 + 1 + ©, and requires you to write down a zeroand carry a one (1 ©). Then the seventh column is 1 + © + © which is aone (and no carry) and the last column is © + ©which is zero. That givesus a result of !©1©1 ©©1 1. WOW!Figure A 1-5 shows another example of adding binary, this tim with acarry off the end.1 '*' 1 1 1 1 '*'8 !1010 1100+ !1110 1010BITBUCKET ! 1001 01 10Figure A1-5.The fi rst column (right-most) gives zero, and both of the next twocolumns give ones. See how simple life is without a carry? The fourthcolumn gives zero, carry one, and the fifth then gives one with no carry.Things warm up a little with the sixth column which gives zero, and carriesone to the seventh. That column then <strong>al</strong>so gives zero and carries on to theeighth column. This makes the eighth addition 1 + 1 + 1 which inevitablygives 11 -write down one and carry one. Since a byte is only eight bitslong, the bit you try to carry to the ninth column f<strong>al</strong>ls into the bit buck<strong>et</strong>

Hooray! Your file is uploaded and ready to be published.

Saved successfully!

Ooh no, something went wrong!