1/20
Looks like no tags are added yet.
Name | Mastery | Learn | Test | Matching | Spaced |
---|
No study sessions yet.
sizeof()
What command can tell us the size (in bytes) of any variable or type?
union my_union {
int i;
float f;
char c;
} my_var;
Declare a union titled my_union containing an int, i, a float, f, and a char, c. The instance variable should be called my_var.
All internal elements overlap.
What is special about the way a union is stored in memory?
enum color {
RED,
GREEN,
BLUE
};
Create an enum titled color with the members RED, GREEN and BLUE.
The order of bytes in a word or multibyte value
What is endianness?
Most significant byte first (lowest address)
How are bytes ordered in big-endian systems?
Least significant byte first (lowest address)
How are bytes ordered in big-endian systems?
12 34 56 78
How would the hexadecimal value 0x12 34 56 78 be stored in a big endian system?
78 56 34 12
How would the hexadecimal value 0x12 34 56 78 be stored in a little endian system?
It compares each bit of two numbers and returns 1 if both corresponding bits are 1, otherwise it returns 0.
What does the & (bitwise AND) operator do?
It compares each bit of two numbers and returns 1 if at least one of the corresponding bits is 1.
What does the | (bitwise OR) operator do?
It compares each bit of two numbers and returns 1 if the corresponding bits are different, otherwise it returns 0.
What does the ^ (bitwise XOR) operator do?
It inverts each bit of a number. All 1 bits become 0, and all 0 bits become 1
What does the ~ (bitwise NOT) operator do?
It shifts the bits of a number to the left by a specified number of positions. This effectively multiplies the number by 2 for each position shifted.
What does the << (bitwise left shift) operator do?
It shifts the bits of a number to the right by a specified number of positions. This effectively divides the number by 2 for each position shifted.
What does the >> (bitwise right shift) operator do?
0001
What is the result of 5 & 3 in binary?
0111
What is the result of 5 | 3 in binary?
0110
What is the result of 5 ^ 3 in binary?
0101
What is the result of ~5 in binary?
1010
What is the result of 5 << 1 in binary?
0010
What is the result of 5 >> 1 in binary?