2.1 Information Storage Flashcards
In binary representations(2 complement) , the most significant bit indicates what
The sign of the number
0 for positive
1 for negative
size of char
8 bit in IA32, 8 bits in x86-64
size of short
16 bit in IA32, 16 bits in x86-64
size of int
32 bit in IA32, 32 bits in x86-64
size of long
32 bit in IA32, 64 bits in x86-64
size of float
32 bit in IA32, 32 bits in x86-64
size of double
64 bit in IA32, 64 bits in x86-64
size of char*
32bit in IA32, 64 bits in x86-64
char *p
p is a pointer to an object of type char
Big Endian
Least Significant byte has HIGHEST address (least significant byte is stored first)
01 23 45 67
Little Endian
Least significant byte has LOWEST address (least significant byte is stored last)
67 45 23 01
When is byte ordering important
When a code is transferred from one machine to another and when inspecting machine level programs
%d
to print a number as signed decimal
%u
to print a number as unsigned decimal
%x
to print a number in hexadecimal format
%p
print pointer
typedef
provides a way of giving a name to a data type in C
Intel byte ordering system
Little Indian
Who uses Big endian
IBM and Oracle
What is a pointer
a variable that stores the memory address of another variable as its value
What is a mask
A bit pattern that indicates a selected set of bits within a word
Logical operations
Logical operations treat any nonzero argument as true and argument 0 as false.
Difference between logical operators and bitwise operators
- The logical operators do not evaluate their second argument if the result of the expression can be determined by evaluating the first term
- The arguments in bitwise operations are restricted to 0s and 1s
Another way to express x==y
(returns 1 when they are equal and 0 otherwise)
!(x^y)