CS374: Programming Language Principles - Data Types
Activity Goals
The goals of this activity are:
- To explain the evolution of data types from a bit perspective
- To explain the storage limitations of primitive data types
- To compose primitive data types from bits
Supplemental Reading
Feel free to visit these resources for supplemental background reading material.
The Activity
Directions
Consider the activity models and answer the questions provided. First reflect on these questions on your own briefly, before discussing and comparing your thoughts with your group. Appoint one member of your group to discuss your findings with the class, and the rest of the group should help that member prepare their response. Answer each question individually from the activity, and compare with your group to prepare for our whole-class discussion. After class, think about the questions in the reflective prompt and respond to those individually in your notebook. Report out on areas of disagreement or items for which you and your group identified alternative approaches. Write down and report out questions you encountered along the way for group discussion.
Model 1: The Bitmap (BMP) File Format
Questions
- What types of primitives do you see in the BMP file format?
Model 2: The IEEE754 Floating Point Standard
Questions
- What primitive data types do you see in this format?
- What fields make up a single-precision floating point value?
- What do you think changes to make a double-precision floating point value?
- Why do you think floating point values suffer from rounding error? How can we compare two floating point values?
- What is the bit representation for an
int
with value 11?
Model 3: Complex Types
Questions
- What is the bit level representation for the
Person
type (with arbitrary values)?
- How would the representation change if
name
was a char*
in the Person
struct or record? What is the advantage of this?
- What is the bit level representation for the
arr
type (with arbitrary values)? How about mat
(specifically, are there 3 rows or 3 columns)?
Model 4: Weakly Typed Languages
Questions
- What is the type of
n
? How about pow
?
- What are some weakly typed languages?
Model 5: Strongly Typed Languages
Questions
- What is the type of
x
? What is its value, and why? How can we correct this to obtain the value we want?
- Given that other languages would compute 1/3 to 0.33333..., how would you define the concept of type coercion?
- What are some strongly typed languages?
- What is the purpose of the
(int*)
clause in the malloc
statement? What does malloc
actually return, and why?
Model 6: Overloading Operators to Work with Complex Types in C++
Questions
- How might you use this to add two
Time
objects together?
Submission
I encourage you to submit your answers to the questions (and ask your own questions!) using the Class Activity Questions discussion board. You may also respond to questions or comments made by others, or ask follow-up questions there. Answer any reflective prompt questions in the Reflective Journal section of your OneNote Classroom personal section. You can find the link to the class notebook on the syllabus.