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 167number (1 1 0xxxxxx). 32 will divide 37 to yield a 1 in the next place(1 101 xxxxx) and a new remainder of 5. 16 and 8 both fail to divide the 5,so we place two more zeros (1 101 00xxx). 4 divides the 5, 2 fails to divid<strong>et</strong>he remainder (1 ), and we are left with a 1. So the last three digits are 101,to give us the binary equ iv<strong>al</strong>ent of 421 as !110100101. The <strong>al</strong>gorithm istedious, but simple-a good candidate for a <strong>computer</strong> program!REMEMBER: When converting decim<strong>al</strong> to binary, divide by the largestpossible power of two to form the quotient and remainder (no decim<strong>al</strong>points!). Take the remainder of the fi rst division and attempt to divide it bythe next lower power of two, and so on, attempting to divide each remainderby the next power of two until you reach a division by 1. Any successfuI division gives you a 1 in the corresponding place, while anunsuccessfu l division yields a 0 in that place.Decim<strong>al</strong> to HexConverting decim<strong>al</strong> to hex follows the same gener<strong>al</strong> outline as decim<strong>al</strong> tobinary, but it is complicated by having sixteen possible v<strong>al</strong>ues for eachdigit instead of two as in binary. When you were dividing by powers oftwo, each power of two went into your number either once, to give you a1, or not at <strong>al</strong>l, which gives you a 0. If your power divided the numbermore than once (two or more), then you knew that you should have beendividing by a higher power_ of two.The unfortunate who converts decim<strong>al</strong> to hex fi nds himself or herselfdividing by powers of sixteen (1, 16, 256, 4096), and a power of sixteenmay divide the number anywhere from zero to fifteen times! For example,l<strong>et</strong>'s convert 1019 to hex.256 is the largest power of sixteen which will divide 1019, and when youperform that division on your c<strong>al</strong>culator, the answer is 3.9804 and so on,so 256 goes into 1019 three times with som<strong>et</strong>hing remaining. That meansyou put a 3 in the 256's place (What 256's place?!). Since this is the firstdivision, the 3 is on the left end of the hex number, and now you need toknow the remainder of the division. To fi nd that (since your c<strong>al</strong>culator isgrossly inaccurate and truncates after ten or fifteen decim<strong>al</strong> places), multiplythree by 256 and subtract the result from 1019 (1019-3x256), to g<strong>et</strong>251.Now divide 251 by the next power of 16 (which happens to be 16 itself),and your c<strong>al</strong>culator will display a fifteen, a decim<strong>al</strong> point, and garbage.The fifteen indicates that you have an "F" (the hex equ iv<strong>al</strong>ent of 1 5) in thenext place of your hex number, which so far looks like $3F, and thedecim<strong>al</strong> point garbage means that you must c<strong>al</strong>culate a new remainder bymultiplying sixteen times "F" (15), and subtracting from 251 (251 -15 x16) to g<strong>et</strong> 11. Therefore, the last digit of the hex number is "B" (the hexequ iv<strong>al</strong>ent of eleven, sil ly!), so the entire number is $3FB. Still a little hazy,

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

Saved successfully!

Ooh no, something went wrong!