UMAINE CIS
Data Types
COS 301 - Programming Languages
Fall 2018
COS 301 — Programming LanguagesUMAINE CIS
Types
- Type – collection of values + operations on them
- Ex: integers:
- values: …, -2, -1, 0, 1, 2, …
- operations: +, -, *, /, <, >, …
- Ex: Boolean:
- values: true, false
- operations: and, or, not, …
UMAINE CIS
Bit Strings
- Computer: Only deals with bit strings
- No intrinsic “type”
- E.g.:
0100 0000 0101 1000 0000 0000 0000 0000 could be: – The floating point number 3.375 – The 32-bit integer 1,079,508,992 – Two 16-bit integers 16472 and 0 – Four ASCII characters: @ X NUL NUL
- What else?
- What about 1111 1111?
UMAINE CIS
Levels of Abstraction
- First: machine language, bit strings
- Then: assembly language
- Mnemonics for operations, but also…
- ...human-readable representations of bit strings
- Then: HLLs
- Virtual machine – hides real machine’s registers, operations,
memory
- Abstractions of data: maps human-friendly abstractions ⇒ bit
strings
- Sophisticated typing schemes for numbers, characters,
strings, collections of data, …
- OO – just another typing abstraction