๐ -> Lecture Date: Name
[Lecture Slide Link]
๐ค Vocab
โ Unit and Larger Context
Finished floating point numbers
Intro to Representation
Floating point numbers are kind of like scientific notation
Floating point numbers are all written:
- m = mantissa
- More bits here the more precision our numbers have
- e = exponent
- More bits here the wider the range of values we can represent
- e is treated as unsigned so as not to waste values, and ranges from values between 0-255 (8-bit). Half of the values are assigned to positive exponents, the other half for negatives. 1 is
10000000(1 + 127 = 128, 128 flips the most significant digit)- Value actually stored is
- Value actually stored is
| Field | Sign | Exponent | Mantissa |
|---|---|---|---|
| Number of bits | 1 | 8 | 23 |
Float Conversion
Decimal to float:
- Find the binary representation of your number
6.25 = 110.01 - Multiply the number by 2^0
110.01 * 2 - Put the number in normal form 1.m increasing/decreasing the exponent to keep the value of the number the same
1.1001 * 2 - The value in the exponent field is e + 127
Exp field = 2 + 127 = 129 = 0b10000001 - If there are fewer than 23 bits in the mantissa field ass 0s to the ned of m until there are 23 bits
M = 1001 followed by 19 0โs - If the number is positive the sign bit is 0, if negative it is 1
Number is positive so sign field is 0 - Put sign,exponent, and mantissa values youโve calculated in the prior steps together in the correct order to get your answer
| Sign | Exponent | Mantissa |
|---|---|---|
| 0 | 10000001 | 1001 and 19 0โs |
| 0 | 10000001 | 10010000000000000000000 |
Special Values
- If exponent field and mantissa are 0, number is 0
- If exponent field is all 1s:
- If the mantissa field is 0 it means the number is infinity
- If the mantissa field is nonzero it means the number is NAN (not a number)
Covered character mapping (ASCII, Unicode)
Arrays
- 1D arrays are stored as a contiguous chunk of memory
ar[i]is shorthand for*(ar + i)
Multi Dimensional Arrays
We can store them multiple ways
- One big chunk of memory allocated:
- This is done for static arrays, like
ar[3][4]
- This is done for static arrays, like
- Array of arrays, we create an array of pointer that then point to each row
- A 3x4 array of ints:
- Create an array of 3 int*
- Each of those pointers points to an array of 4 elements
- This is done for dynamically created arrays
- A 3x4 array of ints:
Row Major:
- Lay the rows of matrix end to end
- C does this
Column Major:
- Lay the columns of the matrix end to end
- R does this
| Indices | 0 | 1 | 2 | 3 |
|---|---|---|---|---|
| 0 | 0 | 1 | 2 | 3 |
| 1 | 4 | 5 | 6 | 7 |
| 2 | 8 | 9 | 10 | 11 |
| Index | 0 | 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | 11 |
|---|---|---|---|---|---|---|---|---|---|---|---|---|
| Value | 0 | 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | 11 |
| Row Major ^ |
| Index | 0 | 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | 11 |
|---|---|---|---|---|---|---|---|---|---|---|---|---|
| Value | 0 | 4 | 8 | 1 | 5 | 9 | 2 | 6 | 10 | 3 | 7 | 11 |
| Column Major ^ |
โ๏ธ -> Scratch Notes
- Log as you go through entry
๐งช-> Example
- List examples of where entry contents can fit in a larger context
๐ -> Related Word
- Link all related words