Docsity

Computer Science Lecture Notes: Introduction to Computing and Notation Systems, Study notes of Computer Science

Toggle sidebar
bg1
CSE 202011 – Lecture 2
Topics
• Introduction to Computing
Variable Notation
Binary Review
• Smallest unit is a bit
Base 2 notation -> Two values
1 (TRUE) 0 (FALSE)
• Nibble
4 bits – 16 possible values
Ratio of 1 Nibble to 1 Hexadecimal character
• Byte, Word, Double Word
8 bits, 16 bits, 32 bits
Three most common forms of notation
Decimal (base 10) 0,1,2,...,9
Hexadecimal (base 16) 0,1,2,...,9, A,B,C,D,E,F
Binary (base 2) 0,1
Another form is octal (base 8)
Binary
0 0000 0000
1 0000 0001
2 0000 0010
3 0000 0011
4 0000 0100
Looking at a nibble
0100
0 * 2^3 + 1*2^2 + 0*2^1 + 0*2^0
Common Powers of 2
2^10 ~ 1 KB
2^20 ~ 1 MB
2^30 ~ 1 GB
2^32 ~ 4 GB
2^40 ~ 1 TB
Is 2^64 enough memory or storage?
Hexadecimal Notation
0x04
$04
Base16 0 … 9 A B C D E F
0 … 9 10 11 12 13 14 15
Converting between forms
Binary to Hexadecimal
pf3
pf4
pf5

Partial preview of the text

Download Computer Science Lecture Notes: Introduction to Computing and Notation Systems and more Study notes Computer Science in PDF only on Docsity!

CSE 202011 – Lecture 2

Topics

• Introduction to Computing

Variable Notation

Binary Review

• Smallest unit is a bit

Base 2 notation - > Two values

1 (TRUE) 0 (FALSE)

• Nibble

4 bits – 16 possible values

Ratio of 1 Nibble to 1 Hexadecimal character

• Byte, Word, Double Word

8 bits, 16 bits, 32 bits

Three most common forms of notation

Decimal (base 10) 0,1,2,...,

Hexadecimal (base 16) 0,1,2,...,9, A,B,C,D,E,F

Binary (base 2) 0,

Another form is octal (base 8)

Binary

Looking at a nibble

0 * 2^3 + 12^2 + 02^1 + 0*2^

Common Powers of 2

2^10 ~ 1 KB

2^20 ~ 1 MB

2^30 ~ 1 GB

2^32 ~ 4 GB

2^40 ~ 1 TB

Is 2^64 enough memory or storage?

Hexadecimal Notation

0x

Base16 0 … 9 A B C D E F

Converting between forms

Binary to Hexadecimal

Each 4 bits is a hexadecimal character

Key Point : Remember, a notation is just a way of representing a specific quantity. A

number is not in hex or in decimal or in binary form. Hex, decimal, and binary are just

ways of representing a specific quantity. It is up to you to decide how to deal with the

variable and how the information is represented.

Example:

Passed in the value 50 in an 8 bit quantity

Binary = 00110010

Hex = 0x

Decimal = 50

Could be the actual number 50

x = x + 50

Could be various bits of information

If bit 6 is set, do this

Could be a combination

If bit 6 is set, x = x + lower nibble of the value

Example:

124 to Binary

Nearest power of 2 that is less than the value

28 – 16 = 12 7 C

4 – 4 = 0 0x7C

Binary = 0111 1100

Hex = 0x7C

Decimal = 124

In-class exercise

Convert 0xDC to decimal

Why do hex - > binary - > decimal?

Need to know what the computer is doing

Pointers / memory

Use hexadecimal frequently

ASCII Table

• ASCII = American Standard Code for Information Interchange

• What is the letter A?

• A is stored internally as a number

• Decimal = 65

• Hex = 0x

• Why is this important?

058 072 03A 00111010 : (colon) 059 073 03B 00111011 ; (semi-colon) 060 074 03C 00111100 < (less than) 061 075 03D 00111101 = (equal sign) 062 076 03E 00111110 > (greater than) 063 077 03F 00111111? (question mark) 064 100 040 01000000 @ (AT symbol) 065 101 041 01000001 A 066 102 042 01000010 B 067 103 043 01000011 C 068 104 044 01000100 D 069 105 045 01000101 E 070 106 046 01000110 F 071 107 047 01000111 G 072 110 048 01001000 H 073 111 049 01001001 I 074 112 04A 01001010 J 075 113 04B 01001011 K 076 114 04C 01001100 L 077 115 04D 01001101 M 078 116 04E 01001110 N 079 117 04F 01001111 O 080 120 050 01010000 P 081 121 051 01010001 Q 082 122 052 01010010 R 083 123 053 01010011 S 084 124 054 01010100 T 085 125 055 01010101 U 086 126 056 01010110 V 087 127 057 01010111 W 088 130 058 01011000 X 089 131 059 01011001 Y 090 132 05A 01011010 Z 091 133 05B 01011011 [ (left/opening bracket) 092 134 05C 01011100 \ (back slash) 093 135 05D 01011101 ] (right/closing bracket) 094 136 05E 01011110 ^ (caret/cirumflex) 095 137 05F 01011111 _ (underscore) 096 140 060 01100000 ` 097 141 061 01100001 a 098 142 062 01100010 b 099 143 063 01100011 c 100 144 064 01100100 d 101 145 065 01100101 e 102 146 066 01100110 f 103 147 067 01100111 g 104 150 068 01101000 h 105 151 069 01101001 i 106 152 06A 01101010 j 107 153 06B 01101011 k 108 154 06C 01101100 l 109 155 06D 01101101 m 110 156 06E 01101110 n 111 157 06F 01101111 o 112 160 070 01110000 p 113 161 071 01110001 q 114 162 072 01110010 r 115 163 073 01110011 s 116 164 074 01110100 t

117 165 075 01110101 u 118 166 076 01110110 v 119 167 077 01110111 w 120 170 078 01111000 x 121 171 079 01111001 y 122 172 07A 01111010 z 123 173 07B 01111011 { (left/opening brace) 124 174 07C 01111100 | (vertical bar) 125 175 07D 01111101 } (right/closing brace) 126 176 07E 01111110 ~ (tilde) 127 177 07F 01111111 DEL (delete)

Programming the Computer

Programming Methods

Machine Code

Low level language - Assembly

Middle level language - C, C++

High level language - BASIC, Visual Basic, Access

Why teach C?

Fairly efficient

Provides an additional level above assembly programming

Ease of Management of large embedded projects

Decent access to I/O

Example: Linux kernel

Written in C

Example: Embedded devices

Many use C

C is a bridge to other languages

Other Languages

C++ Object-oriented paradigm

Java, Javascript Platform-agnostic

Scheme, Lisp

Perl, PHP, Python

Ruby

Smalltalk, Ada, COBOL

Bottom Line:

  • Plenty of languages to choose from
  • Choose the right tool for the job

 How: Experience, colleagues, Internet reviews

Characteristics of Programming Languages

Data and Data Structures

Types

Instruction and Control Flow

How does the program control operate?

Reference Mechanisms and Re-Use

Garbage collection, etc.

Design Philosophies

Compile – Create an executable to run

C / C++, Java

Languages can have both compilers and interpreters

Reference Mechanisms & Re-Use

How do I refer to variables?

Single variable vs. collection of variables (object/struct)

Single instance vs. multiple instances

Variable vs. Array vs. Pointer

How do I allocate new variables?

Allocating memory

Garbage collection vs. user-managed

Memory leaks

Design Philosophies

What is the programming language trying to do?

What is the target?

AI

Database queries

I/O + device interaction

Brief History / Snapshot

1950’s

FORTRAN Scientific / engineering apps

Lisp

1960’s

COBOL

BASIC

1970’s

Pascal

Scheme

C

1980’s

C++

1990’s

Visual Basic

Python

Java

PHP

2000’s

C#