Systems programming · Quick practice

Make the basics automatic.

One small question. Check it. Do another. Fresh numbers, as long as you want.

Changing a setting starts a fresh round; missed questions stay available.

Choose the number bases for bit operations

Applies to bitwise operations, pattern shifts, and masks. Conversions and C expressions use their own stated formats. Decimal pattern results are unsigned.

0 / 0correct
—accuracy
0in a row

Question 1


      

Enter to check

Quick reference & assumptions

Work through every value

Lock onto one conversion, signed representation, or char skill. Each 8-bit pass shows all 256 patterns once in scrambled order: unsigned 0…255 or signed −128…127. One-digit hex passes cover 0…F. Then another pass begins.

Pass progress counts questions shown; review missed questions to correct mistakes. Settings, pass positions, and missed questions are saved in this browser when storage is available. Round scores start fresh. Mixed modes rotate through skills.

Pointer basics

With int x = 7; int *p = &x;, p holds the address of x and *p reads 7. Writing *p = 9; changes x to 9. Array indices start at 0.

The pointer drills use valid objects and one dereference at a time. The type-size drill assumes that object pointers occupy 8 bytes.

Bit weights

From left to right in 8 bits:

128 64 32 16 8 4 2 1

For two’s complement, the first weight becomes −128. A leading 1 means negative. For 8-bit values: unsigned 0…255; signed −128…127.

To negate a fixed-width pattern: invert every bit, then add 1. Keep only the chosen width.

Hex ↔ four bits

Each hex digit represents four bits
HexBinaryHexBinary
0000081000
1000191001
20010A1010
30011B1011
40100C1100
50101D1101
60110E1110
70111F1111

Practice machine

Assumed sizes for type-size questions
TypeBytesBits
char18
short216
int432
long / long long864
float432
double864
Object pointers864

Signed and unsigned versions have the same storage size. These are practice assumptions, not universal C sizes. Integer sizes match the Timberlea examples in Lecture 5. C fact questions explicitly ask about C itself.

Keep the operations separate

& | ^ ~ act on bits. && || ! act on truth and return 0 or 1. Zero is false; any nonzero integer is true.

Bit-pattern questions use exactly the displayed width. A logical right shift fills with 0; an arithmetic right shift copies the sign bit.

C expressions use C17 and 32-bit int/unsigned int. C promotes small integer operands before shifting or complementing. Negative signed right shift is implementation-defined in C17; signed overflow is undefined. The fixed-width exercises specify their own bit operations.

Rule reference: WG14 C draft, §§6.3.1.1, 6.5.3.3–4 and 6.5.7–14; the relevant rules also apply in C17.