Download bits - La Salle University

Survey
yes no Was this document useful for you?
   Thank you for your participation!

* Your assessment is very important for improving the workof artificial intelligence, which forms the content of this project

Document related concepts

Large numbers wikipedia , lookup

Approximations of π wikipedia , lookup

Location arithmetic wikipedia , lookup

Arithmetic wikipedia , lookup

Addition wikipedia , lookup

Elementary mathematics wikipedia , lookup

Positional notation wikipedia , lookup

Transcript
A bit about the computer
Bits, bytes, memory and so on
Some of this material can be found in
Discovering Computers 2000 (Shelly,
Cashman and Vermaat) 3.11-3.13 and the
appendix A.1-A.4.
A computer is
 a person or thing that computes
 to compute is to determine by arithmetic
means (The Randomhouse Dictionary)
 so computing involves numbers
 While typing papers, drawing pictures
and surfing the Net don’t seem to involve
numbers at first, numbers are lurking
beneath the surface
Representing numbers
 Some attribute of the computer is used to
“represent” numbers (for example: a
child’s fingers)
 two kinds of representation are:
– analog the numbers represented take on a
continuous set of values
– digital the numbers represented take on a
discrete set of values
Pros and Cons
 the analog representation is fuller/richer
after all there are an infinite number of
values available
 the digital representation is safer from
corruption by “noise;” there is a big
difference between the various discrete
values, and smaller, more subtle
differences do not affect the
representation
Our computers are
 digital and electronic
 (note that digital  electronic)
 they are electronic because they use an
electronic means (e.g. voltage or current)
to represent numbers
 they are digital because the numbers
represented are discrete
Binary representation
 the easiest distinction to make is between
– low and high voltage
– off and on
then we can only represent two
digits: 0 and 1
 but we can represent any (whole) number
using 0’s and 1’s
Decimal vs. Binary
 Decimal (base 10)
– 124 = 100 + 20 + 4
– 124 = 1  102 + 2  101 + 4  100
 Binary (base 2)
– 1111100 = 64 + 32 + 16 + 8 + 4 + 0 + 0
– 1111100 = 1  26 + 1  25 + 1  24 + 1  23
+ 1  22 + 0  21 + 0  20
Bits and Bytes
 A bit is a single binary digit (0 or 1).
 A byte is a group of eight bits.
 A byte can be in 256 (28) distinct states
(which we might choose to represent the
numbers 0 through 255).
 Note computer scientists like to start
counting with zero.
Realizing a bit
 We need two “states,” e.g.
– high or low voltage (e.g. computer chips)
• why you should protect computer from power surges
– north or south pole of a magnet (e.g. floppy
disks)
• why you should keep floppies away from large magnets
– light or dark (e.g. CD)
– hole or no hole (e.g. punch card or CD)
Representing characters
 Combinations of 0’s and 1’s
be used to represent
can
characters
 This is most commonly done using ASCII
code
American Standard Code for
Information Interchange
ASCII code (a byte per character)
 0 00110000
8 00111000
G 01000111
 1 00110001
9 00111001
H 01001000
 2 00110010
A 01000001
I 01001001
 3 00110011
B 01000010
J 01001010
 4 00110100
C 01000011
K 01001011
 5 00110101
D 01000100
L 01001100
 6 00110110
E 01000101
M 01001101
 7 00110111
F 01000110
N 01001110
More, more, more
 A kilobyte is 1,024 (210) bytes
– approx. one thousand
 A megabyte is 1,048,576 (220) bytes
– approx. one million
 A gigabyte is 1,073,741,824 (230) bytes
– approx. one billion
 A terabyte is 1,099,511,627,776 (240) bytes
– approx. one trillion
Storing it away
 A standard 3.5 inch floppy disk holds
1.44 MB (megabytes)
 An Iomega Zip disk holds approx. 100
MB
– (the computers in Olney 200 have zip drives)
 A CD holds approx. 600 MB
 A typical hard drive holds a few GB
(gigabytes)
Storing the Starr report
 The report plus supporting material
 If there were:
– 60 characters per line
– 66 lines per page (single spaced)
– 500 pages in a ream of paper
– 10 reams in a box
– and 18 boxes
The Grand Total
 N = 60  66  500  10  18
 N = 356,400,000
 N  340 MB (megabytes)
 The Starr report and the accompanying
materials would fit on a few zip disks or
one writable CD.
True or False
 A boolean expression is a condition that is
either true or false (on or off)
 Logical operators:
– like an arithmetic operator (e.g. addition)
that takes in two numbers (operands) and
yields a number as a result (1+1=2)
– Logical operators take in two boolean
expressions and produces a boolean outcome
AND
 use to narrow searches
Bit 1
Bit 2
(Bit 1 AND Bit 2)
0 (false)
0 (false)
0 (false)
0 (false)
1 (true)
0 (false)
1 (true)
0 (false)
0 (false)
1 (true)
1 (true)
1 (true)
Example of “AND”
“Mark McGwire” AND supplement
McGwire’s use of Androstenedione
OR
 use to widen searches
Bit 1
Bit 2
(Bit 1 OR Bit 2)
0 (false)
0 (false)
0 (false)
0 (false)
1 (true)
1 (true)
1 (true)
0 (false)
1 (true)
1 (true)
1 (true)
1 (true)
Example of “OR”
“Mark McGwire” OR “Sammy Sosa”
Either McGwire or Sosa or both
Transistors
 When bits are represented using voltage,
the logical operators (gates) can be
constructed from transistors
 The Pentium ® II has approximately 7.5
million transistors on it
 The transistors have lengths
approximately 0.35 microns (millionths of
a meter)
Extra slides
 The following slides are on converting
numbers from decimal to binary
 Don’t panic. I never ask this on tests.
 I just like to expose people to it.
Decimal  Binary
 Take the decimal number 76
 Look for the largest power of 2 that is less
than 76.
 The powers of 2 are 1, 2, 4, 8, 16, 32, 64,
128, 256, etc.
 So the largest power of 2 less than 76 is
64=26.
Decimal  Binary
(76  1001100)
 Put a 1 on the 26’s place, and subtract 64
from 76 leaving 12.
6
2
5
2
4
2
3
2
2
2
1
2
0
2
1
 Ask if the next lower power of 2, 32=25 is
greater than or less than or equal to what
we have left (12).
Decimal  Binary (76  1001100)
 32 is greater than 12 so we put a 0 in the
25’s place.
6
5
2
2
1
0
4
2
3
2
2
2
1
2
0
2
 16 is greater than 12 so we put a 0 in the
24’s place.
Decimal  Binary (76  1001100)
6
2
5
4
2
2
1
0
0
3
2
2
2
1
2
0
2
 8 is less than 12, so we put a 1 in the 23’s
place, and subtract 8 from 12 leaving 4.
6
2
5
2
4
3
2
2
1
0
0
1
2
2
1
2
0
2
Decimal  Binary (76  1001100)
 4 is equal to 4, so we put a 1 in the 22’s
place, and subtract 4 from 4 leaving 0.
6
2
5
2
4
2
3
2
2
2
1
0
0
1
1
1
2
0
2
 2 is greater than 0 so we put a 0 in the
21’s place.
Decimal  Binary (76  1001100)
6
2
5
2
4
2
3
2
2
1
2
2
1
0
0
1
1
0
0
2
 1 is greater than 0 so we put a 0 in the
20’s place.
6
2
5
2
4
2
3
2
2
2
1
0
2
2
1
0
0
1
1
0
0