Send Close Add comments: (status displays here)
Got it!  This site "robinsnyder.com" uses cookies. You consent to this by clicking on "Got it!" or by continuing to use this website.  Note: This appears on each machine/browser from which this site is accessed.
Counting
by RS  admin@robinsnyder.com : 1024 x 640


1. Counting: importance

2. Importance
Why is counting important?

3. Counting

4. Counting
Computer people often start counting at 0 and not at 1.


5. Value and representation
There is a difference between a value and a representation of a value.

The value is an abstract idea. A representation is a way to make the value (in reality) concrete.

Plato in his philosophy takes the position that the abstract is more "real" than the concrete.

An abstract value has many possible concrete representations.

6. Five
There is one abstract notion of "five". There are many representations and meanings related to "five".

7. Number representation

8. Base 10 digits
Base 10 uses 10 digits, from 0 to 9.
0 1 2 3 4 5 6 7 8 9

Question: What base 10 number comes after 9?

9. Base 10 digits
In base 10, the number 10 comes after 9.

Question: What rule is used to go from 9 to 10?

10. Addition with carry
The 9 goes to 0, with a carry of 1 in the next decimal place.
 1    9 +  1 ----  1 0

In base ten, adding 1 to 9 is 0 with a carry of 1, which is brought down to get 10, or ten.

Note: 9 is the tenth and last digit in base 10.

11. Decimal numbers
Consider the number 156.
156 = 100 + 50 + 6 = 1*100 + 5*10 + 6*1 = 1*102 + 5*101 + 6*100


12. Decimal digits
This positional number system, or Arabic numbering system, is much better than the previously used Roman numeral system. How much difference does it make on a bank check when you add one zero: $1, $10, $100, $1,000, $10,000, etc.

13. Base 16 digits
Base 16 uses 16 digits, where 0 to 9 are the first 10 digits.
0 1 2 3 4 5 6 7 8 9

Question: After 9, what are the other 6 hexadecimal digits?

14. Base 16 digits
The 6 hexadecimal digits after 9 are A, B, C, D, E and F

So base 16 uses 16 digits, where A, B, C, D, E, and F have decimal values 10 through 15.
0 1 2 3 4 5 6 7 8 9 A B C D E F


15. Network card addresses
A network adapter card is used to connect a computer to a network.

Manufacturer's of network adapter cards have arranged for every network card has an address that is unique.

Network adapter card addresses are expressed in hexadecimal, such as 08-00-5A-E4-2B-F7.

Question: What base 16 number comes after F?

16. Base 16
In base 16, the number after F is 10.

Question: What rule is used to go from F to 10 in base 16?

17. Addition with carry
The F goes to 0, with a carry of 1 in the next hexadecimal place.
 1    F +  1 ----  1 0

In base sixteen, adding 1 to F is 0 with a carry of 1, which is brought down to get 10, or one-zero hex, or sixteen decimal.

Note: F is the sixteenth and last digit in base 16.

18. Base 2 digits
Base 2 uses 2 digits.
0 1

Question: What base 2 number comes after 1? The base 2 number after 1 is 10.

Question: What rule is used?

19. Addition with carry
The 1 goes to 0, with a carry of 1.
 1    1 +  1 ----  1 0

In base two, adding 1 to 1 is 0 with a carry of 1, which is brought down to get 10, or one-zero binary, or two decimal.

Note: 1 is the second and last digit in base 2.

20. Which base?

1    1    1   9    F    1 + 1  + 1  + 1 ---  ---  --- 1 0  1 0  1 0

When more than one base is being used, what is 10?

21. Base suffix's
Whenever multiple bases are being used, add a suffix to the number to indicate the base of the number. Note that the abstract notion of "one" does not change and is independent of the base in which the idea is expressed.

22. Which base?
So the ambiguity can be resolved using a suffix.
1        1        1   9 d      F h      1 b + 1 d    + 1 h    + 1 b -----    -----     ---- 1 0 d    1 0 h    1 0 b

10d is ten, 10h is sixteen, and 10b is two.

Note: Programming language notation may differ as to how to specify the base to be used.

23. Bit values
Question: How many values can be represented with 1 bit?

24. Bit values
2 values can be represented with 1 bit

1 bit can represent any 2 values, but not more than 2, and everyone using and communicating using those bits must agree on what those 2 values are.

25. 1 bit
1 bit can represent 2 values: What if you are late to class? That cannot be represented with one bit unless one of the above two values is not used.

26. 2 bits
2 bits can represent 4 values: Note: If you leave for an extended period of time in the middle of class, then this might be approximated by marking you either "late for class" or "departed early" as there are not enough bits used to handle more than 4 cases.

27. Bits and bytes
Inside the computer are bits and bytes. To really understand what is going on, you need to know something about bits and bytes.

28. Bits
A bit, for binary digit, can represent two values.

The two values of a bit are often written as 0 and 1.

You cannot actually see a 0 or 1 inside a computer.

How are the 2 values of a bit represented?

29. Bit as binary digit
Classical bitJohn Tukey (American mathematician and statistician) , working with John von Neumann, coined the term "bit" as "binary digit". The classical "bit" has one of two values, which can be represented as 0 (usually taken as false) and 1 (usually taken as true).

This term was first used in an article by Claude Shannon in 1948.

Information sign More: John Tukey

30. Two values
Here are some ways to represent 2 values of a bit.

31. CD ROM
A original standard CD (Compact Disc) can hold 650 MB of data, or about 5 billion bits. Each bit is either a burned hole or not a burned hole at a certain position on the CD that either reflects light or does not reflect light. That is how the 5 billion bits are created and accessed.

32. Byte

33. Bytes
A byte is made up of 8 bits.

Question: How many values can a byte represent?

34. Values of a byte
A byte can represent 256 values.

Since each bit can represent 2 values, 8 bits can represent 256 values as follows.
2*2*2*2*2*2*2*2 = 28 = 256




35. Nibble
A nibble is half a byte

Yes, the technical term for four bits, or half a byte, is a nibble. Computer engineers are often concerned with the upper nibble (upper 4 bits) and lower nibble (lower 4 bits) of a byte.

36. Words



37. Base two numbers
Here are the base 2 numbers from 0d to 15d.
0000 0100 1000 1100 0001 0101 1001 1101 0010 0110 1010 1110 0011 0111 1011 1111

You need to know these 16 numbers in base 2.

38. Create a list
The hard way to learn the first 16 numbers in base 2 is to memorize them.

The easier way, and what I do, is to write down the list starting at 0000 and ending at 1111.

39. Adding by one
To help you see the pattern, here is the sequence where 1 is added to each binary number starting at 0000.
0000 0100 1000  1100 +  1 +  1 +  1  +  1 ---- ---- ----  ---- 0001 0101 1001  1101 0001 0101 1001  1101 +  1 +  1 +  1  +  1 ---- ---- ----  ---- 0010 0110 1010  1110 0010 0110 1010  1110 +  1 +  1 +  1  +  1 ---- ---- ----  ---- 0011 0111 1011  1111 0011 0111 1011  1111 +  1 +  1 +  1 +   1 ---- ---- ---- ----- 0100 1000 1100 10000


40. Numbers from 0 to 15
Here is the list from 0000b to 1111b.
10 16     2    10 16     2 0d 0h 0000b    8d 8h 1000b 1d 1h 0001b    9d 9h 1001b 2d 2h 0010b   10d Ah 1010b 3d 3h 0011b   11d Bh 1011b 4d 4h 0100b   12d Ch 1100b 5d 5h 0101b   13d Dh 1101b 6d 6h 0110b   14d Eh 1110b 7d 7h 0111b   15d Fh 1111b

Write the numbers from 0 to 15 (decimal) in both hexadecimal and binary. Include suffixes for each.

41. Base 2 bits
The bits of a byte can be numbered from 0 to 7, just as post office mailboxes can have numbers. Each box can contain a 0 or a 1.
  7   6   5   4   3   2   1   0 --------------------------------- | ? | ? | ? | ? | ? | ? | ? | ? | ---------------------------------


42. Binary numbers from 0 to 15
So, Ch is 1100b is 1*8 + 1*4 + 0*2 + 0*1 is 12d.
dec   bin hex base 2 exponential notation  0d 0000b  0h 0*23 + 0*22 + 0*21 + 0*20  1d 0001b  1h 0*23 + 0*22 + 0*21 + 1*20  2d 0010b  2h 0*23 + 0*22 + 1*21 + 0*20  3d 0011b  3h 0*23 + 0*22 + 1*21 + 1*20  4d 0100b  4h 0*23 + 1*22 + 0*21 + 0*20  5d 0101b  5h 0*23 + 1*22 + 0*21 + 1*20  6d 0110b  6h 0*23 + 1*22 + 1*21 + 0*20  7d 0111b  7h 0*23 + 1*22 + 1*21 + 1*20  8d 1000b  8h 1*23 + 0*22 + 0*21 + 0*20  9d 1001b  9h 1*23 + 0*22 + 0*21 + 1*20 10d 1010b  Ah 1*23 + 0*22 + 1*21 + 0*20 11d 1011b  Bh 1*23 + 0*22 + 1*21 + 1*20 12d 1100b  Ch 1*23 + 1*22 + 0*21 + 0*20 13d 1101b  Dh 1*23 + 1*22 + 0*21 + 1*20 14d 1110b  Eh 1*23 + 1*22 + 1*21 + 0*20 15d 1111b  Fh 1*23 + 1*22 + 1*21 + 1*20


43. Magic numbers
A magic number is a number that appears in many places as if it has some special type of meaning.

Many magic numbers in computers are actually base 2 numbers of the form 2n or 2n-1.

44. Magic numbers

  n     2n  2n  0d     1d  0000000000000001b  1d     2d  0000000000000010b  2d     4d  0000000000000100b  3d     8d  0000000000001000b  4d    16d  0000000000010000b  5d    32d  0000000000100000b  6d    64d  0000000001000000b  7d   128d  0000000010000000b  8d   256d  0000000100000000b  9d   512d  0000001000000000b 10d  1024d  0000010000000000b 11d  2048d  0000100000000000b 12d  4096d  0001000000000000b 13d  8192d  0010000000000000b 14d 16384d  0100000000000000b 15d 32768d  1000000000000000b 16d 65536d 10000000000000000b

Notice that the 1 moves to the left one place when the number is multiplied by 2 (in base 2). This is similar to the number 12 multiplied by 10 being 120 in base 10.

45. Magic numbers

  n   2n-1 2n-1  1d     1d 0000000000000001b  2d     3d 0000000000000011b  3d     7d 0000000000000111b  4d    15d 0000000000001111b  5d    31d 0000000000011111b  6d    63d 0000000000111111b  7d   127d 0000000001111111b  8d   255d 0000000011111111b  9d   511d 0000000111111111b 10d  1023d 0000001111111111b 11d  2047d 0000011111111111b 12d  4095d 0000111111111111b 13d  8191d 0001111111111111b 14d 16383d 0011111111111111b 15d 32767d 0111111111111111b 16d 65535d 1111111111111111b


46. Base ten comparison

n    10n 10n 0     0d 00001d 1    10d 00010d 2   100d 00100d 3  1000d 01000d 4 10000d 10000d


47. Base ten comparison

n 10n-1  10n-1 1    9d 00009d 2   99d 00099d 3  999d 00999d 4 9999d 09999d


48. Excel example
Excel spreadsheetAn earlier Excel version had the following limitations, much later increased. The column after Z is AA, then AB, etc. This is a base 26 representation where A is column 1, I is column 9, V is column 22, Z is column 26, AA is column 27, etc. Thus, column IV is
9*26 + 22 = 234 + 22 = 256.

Often, software limits picked by software developers correspond to the above magic numbers, either 1 to 2n or 0 to 2n-1.

49. Powers of 2
Here is the idea behind the NCAA basketball tournament. So, for a n-round tournament, you start with 2n teams so that after n rounds, you have 2n-n = 20 = 1 team left.

Note: To have more than 64 teams in the tournament, one must add another level for some of the teams.


50. Bits
A bit, or binary digit, can represent 2 values.

8 bits make a byte that can represent 256 values.

Suffixes are used to specify the number of bytes, as a power of 2.

51. Kilobyte
1024 bytes make a KB (Kilobyte).
1,000 = 103 1,024 = 210

Since 1000 and 1024 are close in size, one can approximate a KB with 1000.

52. Megabyte
1024 KB make a MB (Megabyte) (slightly more than a million).

53. Gigabyte
1024 MB make a GB (Gigabyte) (about a billion, or thousand million).

A standard CD holds more than half a GB (i.e., 650 MB).

54. Terabyte
1024 GB make a TB (Terabyte) (about a trillion, or million million).

Since you waited this long to take the course (i.e., rather than, say, many years ago) you have additional suffixes to learn.

A standard DVD holds several GB.

55. USA
During February, 2000, the US began using the space shuttle to map over 80% of the entire globe.

The data would take about 15,000 CD's, or about 7 to 10 TB (terabyte) of data.

56. Petabyte
1024 TB make a PB (Petabyte) (about a quadrillion).

57. Wal-Mart
Many years ago, companies such as Wal-Mart passed the PB (petabyte) size for databases.

Information about every purchase made at Wal-Mart ends up in a large database that is used in a variety of ways to improve the competitive position of Wal-Mart.

Other companies do much the same thing.

58. Exabyte
1024 PB make an EB (Exabyte) (about a quintillion).

59. Brontobyte
1024 EB make a BB (Brontobyte) (about a sextillion). How many bytes are in a KB?


60. End of page

by RS  admin@robinsnyder.com : 1024 x 640