ECS 36A Lecture Notes - Lecture 3: Lookup Table, Iterator, Unicode
222 views3 pages
Published on 5 Oct 2018
School
Department
Course
Professor

ECS 36A - Lecture 3 - Control Flow
Review:
8--bit unsigned integer [0,255]
8-bit signed integer [-128, 127] : there is one less positive number because of 0
● signed integers (negative) -- their Most Significant Bit is a 1
Binary:
0...0 → 0...01 → 01...1 → 10...0 → 10...01 → 1...1
UNSIGNED: 0 1 127 -128 -129 255
SIGNED: 0 1 127 -128 -127 -1
Often need multiple bytes to represent integers:
0...0 B0,B1,B2,B3 F...F : Little endian vs Big endian
Let x: U8 = 255 (Rust) → U means unsigned, 8 means 8-bit
Let y: U8 = x+1 → increment x by 1 and results in
INTEGER OVERFLOW
Let x: i8 =1;
Let y: i8 = x-1;
For _ in 0..129 {
y=y-1,
}
Integer Overflow is a vulnerability that is hard to catch, but in python integers can hold values of
arbitrary sizes but you give up SPEED for this. Though you may not have integer overflow in
python, be aware of it.
→ search Bitcoin/ Blockchain Integer Overflow Vulnerabilities
How to represent letters:
- Map out each character using integers
- To represent 62 letters (26 upper 26 lower) how many bits do you need? 6 bits → One
Byte is enough
ASCII → designed where all english numbers & punctuation are mapped using integers less
than 128
● MSB of 0 & 128 is 0
● Referred to as our printable characters
0 ?....?
1 ?....? : ASCII with MSG of 1 are used to rep special characters (control)