Difference between revisions of "CSC103: DT's Notes 1"

From dftwiki3
Jump to: navigation, search
Line 129: Line 129:
 
So let's remember this simple rule; it applies to counting in all number systems, whether they are in base 10  or some other base:
 
So let's remember this simple rule; it applies to counting in all number systems, whether they are in base 10  or some other base:
  
<tanbox>When counting, we always increment the right-most digit by 1.  When this digit must roll-over back to 0, we do so, and increment the digit to its left.  If this one rolls over to 0 as well, then we do so and increment the digit to its left, and so on.
+
<bluebox>When counting, we always increment the right-most digit by 1.  When this digit must roll-over back to 0, we do so, and increment the digit to its left.  If this one rolls over to 0 as well, then we do so and increment the digit to its left, and so on.
</tanbox>
+
</bluebox>
  
 
<br />
 
<br />
Line 192: Line 192:
 
;Exercise
 
;Exercise
  
 
+
<br />
 
:How would we count in base 3?  The answer is that we just need to modify our table of available digits to be 0, 1, 2, and apply the rule we developed above.  Here is a start:
 
:How would we count in base 3?  The answer is that we just need to modify our table of available digits to be 0, 1, 2, and apply the rule we developed above.  Here is a start:
  
Line 201: Line 201:
 
  ...
 
  ...
  
Does that make sense?  Continue and write all the numbers until you reach 1000, in base 3.
+
:Does that make sense?  Continue and write all the numbers until you reach 1000, in base 3.
 
</tanbox>
 
</tanbox>
  
Line 327: Line 327:
  
 
So we have a new rule to add numbers in decimal, but actually one that should hold with any base system:   
 
So we have a new rule to add numbers in decimal, but actually one that should hold with any base system:   
<tanbox>
+
<bluebox>
 
We align the numbers one above the other.  We start with rightmost column of digits.  We take the first digit in the column and start with it in the ''table of digits.''  We then go down the table a number of steps equivalent to the digit we have to add to that number.  Which ever digit we end up on in the table  that's the digit we put down as the answer.  If we have to roll-over when we  go down the table, then we put a 1 in the column to the left.  We then apply the rule to the next column of digits to the left, until we have processed all the columns.
 
We align the numbers one above the other.  We start with rightmost column of digits.  We take the first digit in the column and start with it in the ''table of digits.''  We then go down the table a number of steps equivalent to the digit we have to add to that number.  Which ever digit we end up on in the table  that's the digit we put down as the answer.  If we have to roll-over when we  go down the table, then we put a 1 in the column to the left.  We then apply the rule to the next column of digits to the left, until we have processed all the columns.
</tanbox>
+
</bluebox>
  
 
Ready to try this in binary?  Let's take two binary numbers and add them:
 
Ready to try this in binary?  Let's take two binary numbers and add them:
Line 512: Line 512:
 
<br />
 
<br />
 
<tanbox>
 
<tanbox>
;An Example and Exercise====
+
;An Example and Exercise
 
<br />
 
<br />
Assume we want to build a logical machine that can use the logical operators '''and''', '''or''' and '''not''' to help us buy ice cream for a friend.  The friend in question has very specific taste, and likes ice cream with chocolate in it, ice cream with fruit in it, but not Haagen Dazs ice cream.  This example and exercise demonstrate how we can build such a "machine".
+
:Assume we want to build a logical machine that can use the logical operators '''and''', '''or''' and '''not''' to help us buy ice cream for a friend.  The friend in question has very specific taste, and likes ice cream with chocolate in it, ice cream with fruit in it, but not Haagen Dazs ice cream.  This example and exercise demonstrate how we can build such a "machine".
  
 
</tanbox>
 
</tanbox>

Revision as of 11:59, 5 February 2012

--© D. Thiebaut 08:10, 30 January 2012 (EST)


This section is only visible to computers located at Smith College