Monday, February 28, 2011

how to count in binary
finger party trick

add two binary numbers

not just how a number is encoded
some sense of how the CPU, that is ALU
handles addition (of binary numbers)

ASCII - american standard code for information interchange

http://www.asciitable.com/
internally, letters are stored as numbers
capital A is 65
lowecase A = 97
digit 0 is 48

regular ASCII goes from 0 to 127
2^7 possible values
can store it in 7 bits

extended ascii code
a Text file, if ASCII, usually is one byte per "letter"

File extensions
stuffbeforethedot.extension
used to be:
8chars.3le -- three letter extension

this is from the days of DOS (early DISK OPERATING SYSTEM)

.EXE is a three letter extension meaning executable

.XML

.HTM

.DOC
.XLS
.MDB
.PPT

backwards compatibility

cmd - command prompt
text-based interface to the Operating System
DOS
DOS prompt

Office 2007, longer file extensions
.DOCX
.XLSX
.ACCDB
.PPTX

Tools/Folder Options/View Tab
hide extensions for known file types

Windows uses GUI -- pronounced "gooey"
graphical user interface

Old way: to open a document: first open program. then, file/open and specify the file

New way: file associations. based on the extension part of the filename, Windows knows what program to open.

ASCII is not the only encoding. There is also Unicode.
since greater range, file size will be greater. if 4 bytes per letter, X 4 to get file size

Wednesday, February 23, 2011

lecture #6

The Internet vs. World Wide Web

Internet: a series of connected computers
World Wide Web: a series of connected web pages

other things besides WWW run on the Internet

you can network computers together
Local area networks
LANs

Internet vs. Intranet

ISP (internet service provider); Time warner; Verizon

World wide web: pages connect together using hyperlinks
hello.html
Hypertext markup language

WinSCP

you can use NOTEPAD to edit web pages
web browser: software that reads and interprets HTML

Hypertext markup language

www.w3schools.com
go to the HTML section
read until HTML elements

a computer that serves up web pages is called a "web server"
they serve those web pages to web clients. an internet browser.

computer cs12
http://cs12.cs.qc.cuny.edu/

protocol: an agreed upon way of communicating
http
hypertext transfer protocol
ftp
file transfer protocol
https
secure hypertext transfer protocol

http://en.wikipedia.org/wiki/Http

http session
request

the anatomy of a URL
Uniform Resource Locator
http://en.wikipedia.org/wiki/URL

The syntax is
scheme://domain:port/path?query_string#fragment_id

file:///C:/josh/greetings.html

HW: review questions for lecture book chapter 1

IP address
http://en.wikipedia.org/wiki/IP_address

mostly, you are not anonymous

Quiz 1

A hex chart, in case you need it:
base 16 = hexadecimal

0 = 0000
1 = 0001
2 = 0010
3 = 0011
4 = 0100
5 = 0101
6 = 0110
7 = 0111
8 = 1000
9 = 1001
A = 1010
B = 1011
C = 1100
D = 1101
E = 1110
F = 1111

Wednesday, February 16, 2011

Backup your files
copy onto removable media
backup programs
Norton Ghost

*Dropbox**
Mozy
GMail Drive
Google Docs

Tuesday, February 15, 2011

IBM's Watson plays Jeopardy

Read all about it at Wired Magazine.

See some video at Engadget.

How to obtain Microsoft Office (for PCs)

You can get it from microsoft, in one of three ways:

1) You can use the 60 day free trial, available here:

2) You can buy the full version available for cheap to university students, here:
For this, you will need your QC email, since it requires an email which ends in .edu. $80 is a pretty
good price for the full version of office.

3) For free, you can use Office Web Apps:
These run in your web browser. Unfortunately, Microsoft Access is not included as a Web App, but
it does include PowerPoint, Word, and Excel.

You can get the data files you need for the exercise either by downloading it from Prentice Hall website:

or by bringing in a Flash drive to lab next time and copying the folder onto it.

Monday, February 14, 2011

lecture #5

Reed book, read chapter 1.

First quiz, in lab, next wednesday. covers material up to the end of today.

HW#1:
1) Convert these numbers to binary:
7
14
103

2) Convert these binary numbers to decimal:
11001
110
11
1101

3) Convert those numbers in part 2 to octal.
4) Convert those numbers in part 2 to hexadecimal.

end user software. e.g Microsoft Word

programming software. Integrated development environment for creating end-user software. compiler. things used by programmers to create software.

system software. your operating system. Windows XP. lets you launch programs, manage files. used by other programs.

How do you program a computer?
Computer speaks machine language. 01110101 1111
Do humans speak machine language?

assembly language
mov ax, 4
mov bx, 5
add ax, bx

mov = 1001
add = 1111
ax = 1000
bx = 0001

1001 1000 0100
1001 0001 0101
1111 1000 0001

this process of translating TO / FROM machine language very simple.

http://en.wikipedia.org/wiki/Assembly_language
low-level programming languag

assembler

http://en.wikipedia.org/wiki/Low-level_programming_language

first generation, second generation languages

High-level programming language
http://en.wikipedia.org/wiki/High-level_programming_language

Some C++ code to calculate costs:
http://www.functionx.com/cpp/examples/ifelse1.htm
#include <iostream>
using namespace std;

void main()
{
    unsigned int Miles;
    const double LessThan100 = 0.25;
    const double MoreThan100 = 0.15;
    double PriceLessThan100, PriceMoreThan100, TotalPrice;

    cout << "Enter the number of miles: ";
    cin >> Miles;

    if(Miles <= 100)
    {
        PriceLessThan100 = Miles * LessThan100;
        PriceMoreThan100 = 0;
    }
    else
    {
        PriceLessThan100 = 100 * LessThan100;
        PriceMoreThan100 = (Miles - 100) * MoreThan100;
    }

    TotalPrice = PriceLessThan100 + PriceMoreThan100;

    cout << "\nTotal Price = $" << TotalPrice << "\n\n";
}

compiler or an interpreter
compiler does the translation up front.
takes in C++ sources code. outputs machine language.

interpreter.
does not translate front.
translates as executing, as carrying out the instructions.

C++ compiled.
Javascript interpreted.

First quiz only up to this point.
Quiz does not include book material.

Wednesday, February 9, 2011

lecture #4: a lot of math!

represent bigger numbers by combining bits

an introduction to binary
how to understand binary. this will entail converting binary to decimal.

how to convert decimal to binary. an easy way.

introducing octal numbers.
introducing hexadecimal numbers.

I give links and videos on the blog, so you can review how to do it.

decimal = base 10

google calculator

octal = base 8

3 bits = 8 possible values
0 = 000
1 = 001
2 = 010
3 = 011
4 = 100
5 = 101
6 = 110
7 = 111

to go from base 8 to base 10, use an intermediate base 2. use the lookup chart

to go from base 10 to base 8, use an intermediate base 2. use the lookup chart

4 bits = 16 possibilities = 2^4
0 = 0000
1 = 0001
2 = 0010
3 = 0011
4 = 0100
5 = 0101
6 = 0110
7 = 0111
8 = 1000
9 = 1001
10= 1010
11= 1011
12= 1100
13= 1101
14= 1110
15= 1111

base 16 = hexadecimal

0 = 0000
1 = 0001
2 = 0010
3 = 0011
4 = 0100
5 = 0101
6 = 0110
7 = 0111
8 = 1000
9 = 1001
A = 1010
B = 1011
C = 1100
D = 1101
E = 1110
F = 1111

Binary <--> Decimal Conversion

See here for how to convert a binary number to a decimal number.
See here for how to convert a decimal number to a binary number.

At each of these links, there is a detailed description of the process in text, as well as a video. However, they accidentally put the same video in each. To see how a video of how to convert binary --> decimal, see it on YouTube here.

Actually, I'll also post both videos in this blog post:

Decimal to Binary:


Binary to decimal:


For now, practice with the practice numbers they give at those two links. Eventually, I will assign other binary and decimal numbers to convert for a homework.

Here is an extended ASCII chart.

How to convert between binary and hexadecimal.
How to convert between octal and binary. There are better ways.

Monday, February 7, 2011

lecture #3

lecture 3

memory

bit = binary digit. 0 and 1
binary: base 2

in base n, the digits go from 0 to n-1

RAM - random access memory
using electricity
volatile
short term memory

hard disk drive, floppy disk, CD-ROM
ROM - means read only memory
these are long-term memory
not volatile

now we know how you might store a bit

how do we encode bigger numbers?

http://en.wikipedia.org/wiki/Magnetic_tape

random access memory
book
sequential access memory
scroll

that is why we copy program from long-term memory to short term before running

metaphor
sequential access
*VHS tapes
random access
*DVD

1 bit = 2 possible value
0, 1

2 bits = 4
00
01
10
11

how many possible outfits
5 pants
8 shirts

40
5 x 8
simple combinatorics

3 bits = 8 possible values
000
001
010
011
100
101
110
111

2 x 2 x 2
2^3

4 bits = 16 possibilities = 2^4
0 = 0000
1 = 0001
2 = 0010
3 = 0011
4 = 0100
5 = 0101
6 = 0110
7 = 0111
8 = 1000
9 = 1001
10= 1010
11= 1011
12= 1100
13= 1101
14= 1110
15= 1111

n bits, store 2^n possible values

8 bits = byte
4 bits = nibble
2 bytes = word
4 bytes = dword

1024 bytes = 1 kilobyte (kb) = 2^10 bytes

why 2^10 rather than 10^3?
because if we store a memory address in memory, why waste space? you can store 1024 different positions. we operate in base 2.

1024 x 1024 bytes = 2^20 bytes = 1 megabyte
2^30 bytes = gigabyte
2^40 bytes = terabyte

manufacturers redefined terms to mean powers of 10

trilobite; nothing to do with CS

http://en.wikipedia.org/wiki/Terabyte

speed in hertz
kilohertz, megaherz, gigahertz
http://en.wikipedia.org/wiki/Gigahertz

http://en.wikipedia.org/wiki/Von_Neumann_architecture

swap file

Wednesday, February 2, 2011

lecture #2

qccs12.blogspot.com

blackboard

attendance

Incomplete policy is the same college-wide; you need to request

actual content

what is a computer?
something that computes

what does a "computer" need?
input
output
memory
control
mathematical ability

von Neumann architecture

from special purpose machine to
a universal computer
(general purpose computer)

hardware (physical machine)
software (instructions)

von Neumann architecture
conceptual model of computing

Finite State Automata
Turing Machines

Von Neumann architecture
http://en.wikipedia.org/wiki/Von_Neumann_architecture

look at the diagram there

CPU (central processing unit)
ALU (arithmetic / logic unit)
control unit

Memory (in this case, RAM)

examples of output:
printer
speaker
screen

examples of input:
mouse
keyboard
mike

Adding machine.
program:
1) say "please enter a number"
2) get the number, store it in X
3) say "please enter another number"
4) get the number, store it in Y
5) add X and Y, store it in Z
6) say X "+" Y "=" Z
7) Go to step 1

initially, this program will be stored in long-term memory. hard drive.

double-click, copies it to short-term memory. RAM.

RAM stores instructions and data

control unit has IP (instruction pointer)
IP: 1

data is carried via the "bus"

fetch-execute cycle

with that last step 7, we loop

register; really really short term memory, inside the CPU itself

Did you attend at least once?