Midterm topics
storage of information
memories
· in
computer
↳
memory
is addressed in
bytes y = 2xbit
choices
↳ encode numbers as bits
2 bits,
256) 10 11 0100 4 choices
↳
assign every
char to a # Cup to
inherent meaning
↳
symbols have no
information = bits + context
AMD-64 architecture
↳
encodings of C
language types on
unsigned :
range is 0 to
(232-1)
(32 bits) most significant bit is
signed bit , remaining
11 31 bits
signed :
-
(231) to (23 preserve oneresign bits as normal
↓
unsigned int
two zeros
disadvantage :
(+ 0/-0)
An
number
char
Complement : to negate a
short ① flip bits
0010 >
-
1101 >
-
1110
int
I
② add -
8+ 4 + 1= -
3
long
double
long long
float
~
floating-point representations
↳
scientific notation (ish)
floating -
binary 118/23 1101 .
0101B + 1 1010161
-
.
23
sign bit exp significand
significand exponent
.
4 . 734 =
0100
3 n-bit binary pattern represents
0 75 x2
.
= 1 . 50 j
finite 2" distinct #S
00 1
0 50 x 2 = 1
from
.
floating point
.
↳ add As
0 75 + 0 11 to avoid loss
smallest- largest
.
.
>
4 is +
.
0lg . 11 +
1 0011X22-0011X2
.
of precision
add 127 to exp
: 0011x2129 011000000110011000000 ---0000
, contained
alignment every variable
↳ data
-
ensures will be
within single block of memory
① Add padding between the elements to ensure each element begins
at an offset that is a
multiple of their byte size
② Add padding to end of struct to ensure the struct itself is
a multiple of its
largest member
slooping thre an
array of structs,
each access has stride of 32 bytes)
-
structs size of (structs) =
32
double d; sized for
>
- structs a re
double e ; their worst-cased members
datatype always
load
a has
>
int Xi
an address that's a
float fi
multiple of its size
float ↑
g;
3
padding between struct
members maintains
alignment
Cessentially wasted space
↳ bit defines which
masking -
bits
you
want to keep
,
which bits want to clear
you
to value
:
apply mask
ANDing lextract subset of bits ORing (set subset of bits in
in value) a value
1100 0011 1100 0011 & = AND
1 =
OR
!
000 0
00 ~ = NOT
↳ bit shifting
Shift L, fill R w/O 3 shift R, fill I with
(both signed 1 (signed)/0 Consigned
0000 1101 and unsigned
b 1000 1101 /
3 + +2
00011010
x + X2 d
1) 100 0110
storage of information
memories
· in
computer
↳
memory
is addressed in
bytes y = 2xbit
choices
↳ encode numbers as bits
2 bits,
256) 10 11 0100 4 choices
↳
assign every
char to a # Cup to
inherent meaning
↳
symbols have no
information = bits + context
AMD-64 architecture
↳
encodings of C
language types on
unsigned :
range is 0 to
(232-1)
(32 bits) most significant bit is
signed bit , remaining
11 31 bits
signed :
-
(231) to (23 preserve oneresign bits as normal
↓
unsigned int
two zeros
disadvantage :
(+ 0/-0)
An
number
char
Complement : to negate a
short ① flip bits
0010 >
-
1101 >
-
1110
int
I
② add -
8+ 4 + 1= -
3
long
double
long long
float
~
floating-point representations
↳
scientific notation (ish)
floating -
binary 118/23 1101 .
0101B + 1 1010161
-
.
23
sign bit exp significand
significand exponent
.
4 . 734 =
0100
3 n-bit binary pattern represents
0 75 x2
.
= 1 . 50 j
finite 2" distinct #S
00 1
0 50 x 2 = 1
from
.
floating point
.
↳ add As
0 75 + 0 11 to avoid loss
smallest- largest
.
.
>
4 is +
.
0lg . 11 +
1 0011X22-0011X2
.
of precision
add 127 to exp
: 0011x2129 011000000110011000000 ---0000
, contained
alignment every variable
↳ data
-
ensures will be
within single block of memory
① Add padding between the elements to ensure each element begins
at an offset that is a
multiple of their byte size
② Add padding to end of struct to ensure the struct itself is
a multiple of its
largest member
slooping thre an
array of structs,
each access has stride of 32 bytes)
-
structs size of (structs) =
32
double d; sized for
>
- structs a re
double e ; their worst-cased members
datatype always
load
a has
>
int Xi
an address that's a
float fi
multiple of its size
float ↑
g;
3
padding between struct
members maintains
alignment
Cessentially wasted space
↳ bit defines which
masking -
bits
you
want to keep
,
which bits want to clear
you
to value
:
apply mask
ANDing lextract subset of bits ORing (set subset of bits in
in value) a value
1100 0011 1100 0011 & = AND
1 =
OR
!
000 0
00 ~ = NOT
↳ bit shifting
Shift L, fill R w/O 3 shift R, fill I with
(both signed 1 (signed)/0 Consigned
0000 1101 and unsigned
b 1000 1101 /
3 + +2
00011010
x + X2 d
1) 100 0110