Computers and How They Store Data
Hardware and Software
So… um, what's the difference between hardware and software? →
- hardware - the physical device(s) that a computer is made of
- software - the programs that run on a computer
Hardware
- hardware refers to all of the actual parts that a computer is made of
- computers are composed of several specialized components
- what do you think the main components of a computer are? →
Major Components of a Computer System
- the CPU (Central Processing Unit)
- main memory (also called RAM or Random Access Memory)
- secondary storage
- input devices
- output devices
The CPU (Central Processing Unit)
What does it do? →
- the part of the computer responsible for actually running programs
- modern CPUs are also called microprocessors
- they're tiny computer chips
This may just be for the hardware geeks, but what are some examples of microprocessors? →
- the Intel Core i3 in your laptop
- the Apple A6 in your iPhone or iPad
- the Atmel chip on an Arduino (neeerrrrd!)
Main Memory
What does it do? →
- main memory or RAM (Random Access Memory) is the computer's work area
- it's where the computer stores a running program and the data related to that program
- RAM is volatile; it needs continuous power to store data
- consequently, RAM is temporary storage
- when your computer is turned off, the content that's stored in main memory is wiped out
Secondary Storage
What does it do? →
- secondary storage devices - devices meant to store data for long periods of time
- unlike RAM, these storage devices are non-volatile - they do not require power to retain data
What are some examples of non-volatile data stores? →
- your hard drive or SSD
- CDs, DVDs, etc.
- floppy disks (!?)
These devices allow:
- a user to send data to the computer
- or allow the computer to present data or feedback to a user
What are some examples of input and output devices? →
- input - your desktop computer's keyboard and mouse
- input - the camera on your laptop
- input and output - the touch screen on your phone
- output - the speaker on your laptop
Software
Hardware is nice and all, but…
- a computer by itself is pretty inert
- in order to do anything with it, you'll need some software
- that is, you'll need a program or two
- (or… I guess you can call them apps as well, if you really want to)
Types of Software
- operating systems (and other system software)
- the most fundamental set of programs on a computer
- allows interaction with the underlying hardware
- application software
- programs that are actually useful for everyday tasks
- what are some examples of operating systems and applications? →
- operating systems - Windows, Linux, Android, iOS
- applications - Chrome, mail.app, Excel, ProTools, Avid
It's All 0's and 1's
- computers deal with data as a series of bits or binary digits
- a bit (binary digit) can hold only one of two values, a 0 or 1
- turns out, storing 0's and 1's is convenient for computers. why? →
- easily represented by electronics!
- 0 and 1 are essentially analogous to off and on
- (or in actuality the presence or absence of a specific charge or voltage)
Bits
How many pieces of information can be encoded into 1 bit? →
How about 2 sequential bits? →
- 4 (2 x 2) pieces of information (or 4 different combinations of 0's and 1's):
Bytes
A byte is 8 bits. How many possible combinations of 0's and 1's are there in 8 bits? →
- 256 possible combinations (2 x 2 x 2 x 2 x 2 x 2 x 2 x 2)!
- computers can use a byte to encode different kinds of data!
Storing Numbers
Using a binary numbering system, a computer can store the numbers 0 through 255 in a single byte.
- a series of 8 bits represents numbers 0 to 255
- each bit is in a place: _ _ _ _ _ _ _ _
- each place represents the presence or absence of a power of 2:
- summing all of the places gives the decimal version…
- an example: 00101000
Storing Numbers Continued
- the first bit represents either 0 or 1 … 1's
- the second bit represents either 0 or 1 … 2's
- the third bit represents either 0 or 1 … 4's
- the fourth bit represents either 0 or 1 … 8's
- …. and so on through the 8th bit, or 2 to the 7th, which represents 128 (notice that each place is just a power of 2, starting at 2 to the 0th power!)
- all of these added together give a number between 0 and 255
- sometimes this is called a base-2 numeral system
- how does a base-10 numeral system work?
Storing Numbers - Examples
- 00011100
- (0 x 128) + (0 x 64) + (0 x 32) + (1 x 16) + (1 x 8) + (1 x 4) + (0 x 2) + (0 x 1)
- → 28
- 01000010
- (0 x 128) + (1 x 64) + (0 x 32) + (0 x 16) + (0 x 8) + (0 x 4) + (1 x 2) + (0 x 1)
- → 66
Storing Numbers - Questions
00000001 →
1
00000010 →
2
00000011 →
3
00000100 →
4
Storing Numbers - Questions Continued
10000101 →
133
10000001 →
129
00100000 →
32
An Addendum to Storing Numbers
- note that this works well for integers…
- specifically 0 through 255
- to work with more numbers, use more bits!
- there are also other encoding schemes
- what are some other characteristics of numbers that can be encoded? →
- sign (negative or positive numbers)
- decimal point (real / floating point numbers)
Storing Letters and Other Characters
Storing numbers is a breeze - using bits to represent binary numbers works well. How do you think letters and punctuation are stored using bits? →
Since it's easy to store numbers, use some sort of encoding scheme that translates numeric values into characters.
ASCII
One encoding scheme is called ASCII.
- ASCII defines a set of numeric codes that can be translated to English letters, punctuation marks and other characters
- the first version of ASCII stored characters in 7 bits
How many different characters can be stored in 7 bits? →
ASCII Continued
ASCII is an older encoding scheme that has some flaws. What do you think ASCII's major shortcoming is? →
- it can only store 128 English characters!
- what about additional alphabets and writing systems?
- (for example Chinese characters number in the tens of thousands)
Unicode
The current standard for consistently representing text through different character sets and encodings is called unicode.
- in unicode, code points are numbers (specifically integers) that represents a character or glyph
- the most current version of unicode supports 110,000 characters
- here's a table of code points
- note that 65-90 are uppercase latin letters; 97-122 are lowercase
- this matches the older, but limited encoding scheme, ASCII
- here's a unicode snowman
OK… So, How Does a Program Actually Run?
How is a Program Executed?
What part/component of your computer is responsible for executing a program?
The CPU Revisited
The CPU can perform some very basic tasks and operations:
- add, subtract, divide and multiply
- read a piece of data from memory
- move data around from one place in memory to another
- …and others
These operations vary from processor to processor by design.
Machine Language
The CPU executes its operations based on instructions specified by a program. However, computers really only understand 0's and 1's
- these instructions are written in machine language, or machine code
- every kind of processor has its own machine code instruction set
- machine code instructions are patterns of bits that correspond to different commands/operations on the processor
- for example, 00000101 may mean subtract one from the data that's in this location
Don't Panic. We Won't be Programming in Machine Language!