CSCI 223 Quiz 3 Flashcards
how to convert from decimal to hexadecimal
divide by 16, read the remainders from bottom to top
how to convert from decimal to binary
divide by 2, use the remainders from bottom to top (should be 0s and 1s)
how to convert from hexadecimal to decimal
label the positions from right to left as 0, 1, 2, … and multiply the number by 16^? and add the results together
how to convert from binary to decimal
label the positions from right to left as 0, 1, 2, … and multiply the number by 2^? and add the results together
how to convert from binary to hexadecimal or binary to hexadecimal
use the chart
0x0
0000
0x1
0001
0x2
0010
0x3
0011
0x4
0100
0x5
0101
0x6
0110
0x7
0111
0x8
1000
0x9
1001
0xA
1010
0xB
1011
0xC
1100
0xD
1101
0xE
1110
0xF
1111
Little Endian ordering
least significant byte (furthest to the right) has lowest address
pointer
a variable whose content is a memory address
how to declare a pointer
int *p;
and chart
& 0 1
0 0 0
1 0 1
or chart
0 1
0 0 1
1 1 1
not chart
0 1
~ 1 0
exclusive or chart
^ 0 1
0 0 1
1 1 0
logical operations in C (logical and, logical or, logical not)
&&, ||, !
view zero as (true/false) and anything nonzero as (true/false)
false, true
for logical or, you want to place the more likely term to be (0 or 1) first
1
for logical and, you want to place the more likely term to be (0 or 1) first
0
left shift x «_space;y will
shift bit-vector x left by y positions: throw away extra bits on left and will with 0’s on the right; similar to multiplication by 2^x
right shift x»_space; y will
shift bit-vector x right by y positions; similar to division by power of 2
logical right shift
fill with zero’s on the left
arithmetic right shift
replicate the most significant bit to the right on the left