CS 280, Lesson 11 and 12: Data types

0.0(0)
Studied by 0 people
call kaiCall Kai
learnLearn
examPractice Test
spaced repetitionSpaced Repetition
heart puzzleMatch
flashcardsFlashcards
GameKnowt Play
Card Sorting

1/23

encourage image

There's no tags or description

Looks like no tags are added yet.

Last updated 10:15 PM on 4/1/26
Name
Mastery
Learn
Test
Matching
Spaced
Call with Kai

No analytics yet

Send a link to your students to track their progress

24 Terms

1
New cards

data type definition

collection of data objects and a set of predefined operations on those objects;
stored value (instructions and data) in memory are untyped, as hardware on most machines makes no attempt to keep track of which interpretations correspond to which locations in memory

2
New cards

type checking

activity of ensuring that the operands of an operator are of compatible types

3
New cards

type error

the application of an operator to an operand of an inappropriate type

4
New cards

strongly typed programming language

type errors are always detected

5
New cards

type system of a programming language

Defines how a type is associated with each expression in the language and includes its rules for type equivalence and type compatibility

6
New cards

descriptor, and difference between descriptor of static and dynamic variables

collection of the attributes of a variable that are used for type checking and performing allocation and deallocation operations

7
New cards

structured vs scalar data types

scalar data types are those that include a single value, like int, bool, double, etc.
structured data types are those which include composite values, like arrays.

8
New cards

primitive data types

data types that cannot be represented in terms of other data types

9
New cards

what does sizezof operator do in C/C++

it gives the size of the variable or data type in bytes

10
New cards

integer primitive type

  1. what are they in non-decreasing order?

  2. what is the fixed size of byte? short? int? long? in java*

  3. signed vs unsigned integers, qu’est-ce que c’est?

  4. can an integer be declared as unsigned

  1. char, short, int, long, long long

  2. 1,2,4,8

  3. one of the bits in the integer is represented as a sign bit

  4. yes

11
New cards

what is two’s complement rule?

hardware representation of signed integers in binary: take the COMPLEMENT of the binary rep of the number, and then add one.

12
New cards

floating point primitive type

  1. what is the c++ data types of this, in non-decreasing order of size

  2. defined in terms of ____ and ____.

  3. what is the formula to convert a 32-bit binary string into a decimal number?

  4. are they always like hardware?

  1. float, double, long double

  2. precision and range

  3. value = sign x mantissa x 2^{exp}, where sign is a plus or minus, the 2^{exp} has exp = 8 bits after sign - 127; manitssa is the rest of the digits where you concat a “1.” at start, and then for each binary digit starting with the leftmost one (after exponent), you multiply that digit by (0.5), (0.25), (0.125), and onwards.

  4. usually, but not always.

13
New cards

boolean primitive type

  1. is it implemented as bits or bytes?

  2. what are allowable ops?

  1. can be implemented as bits, but usually bytes

  2. the logical !, ||, &&, and relational operations

14
New cards

char primitive type

  1. what are they stored as? (braindead) what is the most commonly used one?

  2. size of char in C++ vs java

  3. what is the c++ data type for unicode characters

  1. numbers (numeric codings); ASCII, or Extended ASCII (128, 256 chars respectively)

  2. 1 byte and 2 bytes

  3. wchar_t

15
New cards

character string data type

  1. is this primitive in C and C++?

  2. is it primitive in Python?

  3. how is this different than Strings in java?

  4. which 3 kinds of strings are of static length?

  5. which languages can implemented strings as limited dynamic and how?

  6. what does the compile time descriptor look like for static strings

  7. what does the run time descriptor look like for limited dynamic strings?

  1. no

  2. ja

  3. it is not. Java string class is just character strings.

  4. java’s string class, c++ standard string, and python string

  5. C and C++ with the string-end being a unique character

  6. static string ; length ; address

  7. limited dynamic string; max length; curr length; address

16
New cards

enums

  1. what are rules for constant appearance in declaration

  2. can you set integer to enum constant? int x = Mon;

  3. can you set enum constant to any datatype? how do you do it legally?

  4. what is the only way to do incrementation / decrementation?

  5. enums vs scoped enums in terms of what you’re allowed to do with adding consts and assigning ints

  1. it can only appear once

  2. ja

  3. no. only way to do it legally: const = (enumName) 4; (4 is an arbitrary int)

  4. const = (enumName) (const + 1);

  5. enums don’t care about adding consts, they treat it as integers, but they don’t let you IMPLICITLY set consts to random nums but you can do so EXPLICITLY. scoped enums don’t let you add consts, and they work the same for setting consts to random ints.

17
New cards

pointers

  1. what are the two possible values?

  2. what is size?

  3. what is indirect accessing?

  4. what are dangling pointers? remember code example.

  5. what is a lost heap-dynamic variable? what is another name for that variable?

  6. pointer arithmetic formula?

  7. what does doing ptr++ or ++ptr , ptr—, —ptr do?

  8. what happens when you subtract two pointers?

  9. can you add, multiply, or divide pointers?

  10. can you do math on void*?

  11. consider some index i inside an array arr . explain relationship with pointer.

  12. what are void pointers and their rules?

  13. is this legal or not, and why: int* p = malloc(sizeof(int)); ?

  1. any memory address or NULL

  2. 8 bytes

  3. accessing a variable in two steps, first by using a pointer that gives the location of var in memory

  4. pointer that points to heap dynamic variable which has been deallocated.

  5. it’s a dynamic variable that is no longer being pointed to, meaning its inaccessible and GARBAGE.

  6. new address = old_address + n*(sizeof(type))

  7. move pointer to next element in memory or prev

  8. only allowed when both point to same array, and it gives the number of elements between the two pointers

  9. no. never.

  10. no.

  11. arr[i] = *(arr + i) = *(i + arr) + i[arr]

  12. they can point to literally any type of variable. however, you cannot deference them or do ANY kind of pointer arithmetic. you must cast them into a normal pointer to deference and shit.

  13. ts NOT legal in C++, but legal in C. since malloc memory is of void, you gotta cast the RHS to (int*)

18
New cards

can you have a reference of a reference? can you have a pointer to a reference?

no, no.

19
New cards

lvalue vs rvalue references

lvalue

  • declared by placing a & a type

  • synonym for the object it references

  • cannot set equal to literal made strings “hello” or substrings

rvalue

  • declared by placing && a type

  • same as lvalue, but can set to literal temp strings and substrings like string && x = “hello”;

20
New cards

references are references to ____ instead of being ______.

objects, addresses.

21
New cards

pointers widen what?

range of references to memory cells that can be accessed by a variable

22
New cards

what data types can be used as indices for arrays

char, bool, short, int, long

23
New cards

what is unique about java arrays (& variables declared as arrays in Java)

they are objects. such variables are references to the array objects and have memory allocated to them. we always know how many items are in them.

24
New cards

Explore top notes

note
Unit 1 Health
Updated 454d ago
0.0(0)
note
Design and Tech - Electricity
Updated 1583d ago
0.0(0)
note
The Hate U Give
Updated 1255d ago
0.0(0)
note
Chapter 2: States
Updated 1093d ago
0.0(0)
note
Glaciation
Updated 580d ago
0.0(0)
note
The Geography of Food and Health
Updated 107d ago
0.0(0)
note
unit 7 study guide
Updated 415d ago
0.0(0)
note
Unit 1 Health
Updated 454d ago
0.0(0)
note
Design and Tech - Electricity
Updated 1583d ago
0.0(0)
note
The Hate U Give
Updated 1255d ago
0.0(0)
note
Chapter 2: States
Updated 1093d ago
0.0(0)
note
Glaciation
Updated 580d ago
0.0(0)
note
The Geography of Food and Health
Updated 107d ago
0.0(0)
note
unit 7 study guide
Updated 415d ago
0.0(0)

Explore top flashcards

flashcards
TEST no10 CAPITALS
126
Updated 24d ago
0.0(0)
flashcards
AP Human Geography Unit 4b
40
Updated 365d ago
0.0(0)
flashcards
Professionalism and Ethics
25
Updated 919d ago
0.0(0)
flashcards
exam 2 - id
48
Updated 171d ago
0.0(0)
flashcards
Les Français et les loisirs
37
Updated 956d ago
0.0(0)
flashcards
A. [Practice Questions] Part 1
111
Updated 123d ago
0.0(0)
flashcards
Ch. 8 "The Civil War"
45
Updated 419d ago
0.0(0)
flashcards
TEST no10 CAPITALS
126
Updated 24d ago
0.0(0)
flashcards
AP Human Geography Unit 4b
40
Updated 365d ago
0.0(0)
flashcards
Professionalism and Ethics
25
Updated 919d ago
0.0(0)
flashcards
exam 2 - id
48
Updated 171d ago
0.0(0)
flashcards
Les Français et les loisirs
37
Updated 956d ago
0.0(0)
flashcards
A. [Practice Questions] Part 1
111
Updated 123d ago
0.0(0)
flashcards
Ch. 8 "The Civil War"
45
Updated 419d ago
0.0(0)