Saturday, May 15, 2010

Introduction to Computer Science - Lecture 4 - Binary Numbers, Programming Languages, Working in Linux, and Programming in C

This is the first of my summaries of various online courses. This is a summary of Lecture 4 of Introduction to Computer Science by D Malan at Harvard.
__________________________________________________

Lecture 4 - Binary Numbers, Programming Languages, Working in Linux, and Programming in C

How many numbers can you represent in an x bit value:
8 bit = 256
16 bit = 65,536
24 bit = 16.7million
32 bit = 4bill

Representing negative numbers:
I) Sign magniture approach (flipping the left most digit)
+3 = 0011
-3  = 1011
or
II) One's complement (take the positive representation of the number and flip the bits)
-3 = 1100

III) Two's complement representation of negative numbes (flip the bits and add 1)
-3 = 1101

Adding two numbers  in binary similar to adding numeric numbers:
4            0100
+3          0011
=
7            0111

adding two numbers, using 2's complement to represent negative numbers:
4                             0100
+ -3                        1101
=
1                              0001  

2's complement is most frequently used.


Types of Programming Languages
I) C++, C->compiler->[OBJECT CODE]
[OBJECT CODE] = hardware\platform specific
compiled programming languages

II) java->VM-> bytecode

III) Perl, PhP, Pythod
interpreted programming language

Linux commands
ls = list contents of current folder
pwd = present working directory (where you are in the system, full)
cd = change directory
mkdir = make directory
cp = copy
mv = move
rm = remove file
man = manual