| {"task_id": "cs-000", "category": "integers", "prompt": "Interpret the 32-bit pattern 0xfffffffe as (a) a two's-complement signed int and (b) an unsigned int. Return one row [signed, unsigned].", "api_description": "You are answering machine-level computer-systems questions by COMPUTING the\nanswer in Python, not by recalling it.\n\nAvailable imports: struct, math (nothing else is needed).\n\nPython's integers are unbounded and its `>>` is always an arithmetic shift, so C's fixed-width\nbehaviour must be emulated deliberately. Two helpers you will want:\n\n def to_signed(v, bits): # interpret the low `bits` bits of v as two's complement\n v &= (1 << bits) - 1\n return v - (1 << bits) if v >> (bits - 1) else v\n\n def to_unsigned(v, bits): # the same bits read as unsigned\n return v & ((1 << bits) - 1)\n\nAnd for IEEE-754: `struct.pack('>f', x)` / `struct.unpack('>f', b)` for single precision,\n`'>d'` for double.\n\nPut the requested values in `result` as a list of rows of plain values. Hex strings are always\nlowercase with a `0x` prefix and the full width of the type (e.g. a 32-bit pattern is\n`0x0000002a`, not `0x2a`).\n", "expected_output": "{\"rows\": [[-2, 4294967294]]}"}
|
| {"task_id": "cs-001", "category": "integers", "prompt": "Give the 32-bit two's-complement bit pattern of -1000 as a lowercase hex string, 8 digits, '0x' prefixed. Return one row [pattern].", "api_description": "You are answering machine-level computer-systems questions by COMPUTING the\nanswer in Python, not by recalling it.\n\nAvailable imports: struct, math (nothing else is needed).\n\nPython's integers are unbounded and its `>>` is always an arithmetic shift, so C's fixed-width\nbehaviour must be emulated deliberately. Two helpers you will want:\n\n def to_signed(v, bits): # interpret the low `bits` bits of v as two's complement\n v &= (1 << bits) - 1\n return v - (1 << bits) if v >> (bits - 1) else v\n\n def to_unsigned(v, bits): # the same bits read as unsigned\n return v & ((1 << bits) - 1)\n\nAnd for IEEE-754: `struct.pack('>f', x)` / `struct.unpack('>f', b)` for single precision,\n`'>d'` for double.\n\nPut the requested values in `result` as a list of rows of plain values. Hex strings are always\nlowercase with a `0x` prefix and the full width of the type (e.g. a 32-bit pattern is\n`0x0000002a`, not `0x2a`).\n", "expected_output": "{\"rows\": [[\"0xfffffc18\"]]}"}
|
| {"task_id": "cs-002", "category": "integers", "prompt": "The 8-bit signed value -76 is sign-extended to 32 bits, and separately the same 8 bits are zero-extended to 32 bits. Return one row [sign_extended value as a signed int, zero_extended value as an int].", "api_description": "You are answering machine-level computer-systems questions by COMPUTING the\nanswer in Python, not by recalling it.\n\nAvailable imports: struct, math (nothing else is needed).\n\nPython's integers are unbounded and its `>>` is always an arithmetic shift, so C's fixed-width\nbehaviour must be emulated deliberately. Two helpers you will want:\n\n def to_signed(v, bits): # interpret the low `bits` bits of v as two's complement\n v &= (1 << bits) - 1\n return v - (1 << bits) if v >> (bits - 1) else v\n\n def to_unsigned(v, bits): # the same bits read as unsigned\n return v & ((1 << bits) - 1)\n\nAnd for IEEE-754: `struct.pack('>f', x)` / `struct.unpack('>f', b)` for single precision,\n`'>d'` for double.\n\nPut the requested values in `result` as a list of rows of plain values. Hex strings are always\nlowercase with a `0x` prefix and the full width of the type (e.g. a 32-bit pattern is\n`0x0000002a`, not `0x2a`).\n", "expected_output": "{\"rows\": [[-76, 180]]}"}
|
| {"task_id": "cs-003", "category": "integers", "prompt": "For 32-bit ints, compute INT_MIN, INT_MAX, and the value of -INT_MIN when it wraps in 32-bit two's complement. Return one row [INT_MIN, INT_MAX, negated_INT_MIN].", "api_description": "You are answering machine-level computer-systems questions by COMPUTING the\nanswer in Python, not by recalling it.\n\nAvailable imports: struct, math (nothing else is needed).\n\nPython's integers are unbounded and its `>>` is always an arithmetic shift, so C's fixed-width\nbehaviour must be emulated deliberately. Two helpers you will want:\n\n def to_signed(v, bits): # interpret the low `bits` bits of v as two's complement\n v &= (1 << bits) - 1\n return v - (1 << bits) if v >> (bits - 1) else v\n\n def to_unsigned(v, bits): # the same bits read as unsigned\n return v & ((1 << bits) - 1)\n\nAnd for IEEE-754: `struct.pack('>f', x)` / `struct.unpack('>f', b)` for single precision,\n`'>d'` for double.\n\nPut the requested values in `result` as a list of rows of plain values. Hex strings are always\nlowercase with a `0x` prefix and the full width of the type (e.g. a 32-bit pattern is\n`0x0000002a`, not `0x2a`).\n", "expected_output": "{\"rows\": [[-2147483648, 2147483647, -2147483648]]}"}
|
| {"task_id": "cs-004", "category": "integers", "prompt": "In 32-bit signed arithmetic, does 2000000000 + 2000000000 overflow, and what value results after wrapping? Return one row [overflowed as a bool, wrapped result as a signed int].", "api_description": "You are answering machine-level computer-systems questions by COMPUTING the\nanswer in Python, not by recalling it.\n\nAvailable imports: struct, math (nothing else is needed).\n\nPython's integers are unbounded and its `>>` is always an arithmetic shift, so C's fixed-width\nbehaviour must be emulated deliberately. Two helpers you will want:\n\n def to_signed(v, bits): # interpret the low `bits` bits of v as two's complement\n v &= (1 << bits) - 1\n return v - (1 << bits) if v >> (bits - 1) else v\n\n def to_unsigned(v, bits): # the same bits read as unsigned\n return v & ((1 << bits) - 1)\n\nAnd for IEEE-754: `struct.pack('>f', x)` / `struct.unpack('>f', b)` for single precision,\n`'>d'` for double.\n\nPut the requested values in `result` as a list of rows of plain values. Hex strings are always\nlowercase with a `0x` prefix and the full width of the type (e.g. a 32-bit pattern is\n`0x0000002a`, not `0x2a`).\n", "expected_output": "{\"rows\": [[true, -294967296]]}"}
|
| {"task_id": "cs-005", "category": "integers", "prompt": "Take the 32-bit pattern of -20. Shift it right by 3 as C would for a SIGNED int (arithmetic) and as C would for an UNSIGNED int (logical). Return one row [arithmetic result as a signed int, logical result as an unsigned int].", "api_description": "You are answering machine-level computer-systems questions by COMPUTING the\nanswer in Python, not by recalling it.\n\nAvailable imports: struct, math (nothing else is needed).\n\nPython's integers are unbounded and its `>>` is always an arithmetic shift, so C's fixed-width\nbehaviour must be emulated deliberately. Two helpers you will want:\n\n def to_signed(v, bits): # interpret the low `bits` bits of v as two's complement\n v &= (1 << bits) - 1\n return v - (1 << bits) if v >> (bits - 1) else v\n\n def to_unsigned(v, bits): # the same bits read as unsigned\n return v & ((1 << bits) - 1)\n\nAnd for IEEE-754: `struct.pack('>f', x)` / `struct.unpack('>f', b)` for single precision,\n`'>d'` for double.\n\nPut the requested values in `result` as a list of rows of plain values. Hex strings are always\nlowercase with a `0x` prefix and the full width of the type (e.g. a 32-bit pattern is\n`0x0000002a`, not `0x2a`).\n", "expected_output": "{\"rows\": [[-3, 536870909]]}"}
|
| {"task_id": "cs-006", "category": "integers", "prompt": "In 8-bit two's complement, compute (char)200 — that is, the low 8 bits of 200 read as signed — and then multiply that by 3, again in 8-bit wrapping arithmetic. Return one row [cast_value, product].", "api_description": "You are answering machine-level computer-systems questions by COMPUTING the\nanswer in Python, not by recalling it.\n\nAvailable imports: struct, math (nothing else is needed).\n\nPython's integers are unbounded and its `>>` is always an arithmetic shift, so C's fixed-width\nbehaviour must be emulated deliberately. Two helpers you will want:\n\n def to_signed(v, bits): # interpret the low `bits` bits of v as two's complement\n v &= (1 << bits) - 1\n return v - (1 << bits) if v >> (bits - 1) else v\n\n def to_unsigned(v, bits): # the same bits read as unsigned\n return v & ((1 << bits) - 1)\n\nAnd for IEEE-754: `struct.pack('>f', x)` / `struct.unpack('>f', b)` for single precision,\n`'>d'` for double.\n\nPut the requested values in `result` as a list of rows of plain values. Hex strings are always\nlowercase with a `0x` prefix and the full width of the type (e.g. a 32-bit pattern is\n`0x0000002a`, not `0x2a`).\n", "expected_output": "{\"rows\": [[-56, 88]]}"}
|
| {"task_id": "cs-007", "category": "integers", "prompt": "For a 32-bit UNSIGNED int, compute 5 - 9 with wraparound, and state whether the C comparison (5u - 9u) > 0 is true. Return one row [wrapped difference, comparison as a bool].", "api_description": "You are answering machine-level computer-systems questions by COMPUTING the\nanswer in Python, not by recalling it.\n\nAvailable imports: struct, math (nothing else is needed).\n\nPython's integers are unbounded and its `>>` is always an arithmetic shift, so C's fixed-width\nbehaviour must be emulated deliberately. Two helpers you will want:\n\n def to_signed(v, bits): # interpret the low `bits` bits of v as two's complement\n v &= (1 << bits) - 1\n return v - (1 << bits) if v >> (bits - 1) else v\n\n def to_unsigned(v, bits): # the same bits read as unsigned\n return v & ((1 << bits) - 1)\n\nAnd for IEEE-754: `struct.pack('>f', x)` / `struct.unpack('>f', b)` for single precision,\n`'>d'` for double.\n\nPut the requested values in `result` as a list of rows of plain values. Hex strings are always\nlowercase with a `0x` prefix and the full width of the type (e.g. a 32-bit pattern is\n`0x0000002a`, not `0x2a`).\n", "expected_output": "{\"rows\": [[4294967292, true]]}"}
|
| {"task_id": "cs-008", "category": "integers", "prompt": "Left-shift 0x40000000 by 1 and by 2 in a 32-bit SIGNED int, wrapping each time. Return one row [after one shift as a signed int, after two shifts as a signed int].", "api_description": "You are answering machine-level computer-systems questions by COMPUTING the\nanswer in Python, not by recalling it.\n\nAvailable imports: struct, math (nothing else is needed).\n\nPython's integers are unbounded and its `>>` is always an arithmetic shift, so C's fixed-width\nbehaviour must be emulated deliberately. Two helpers you will want:\n\n def to_signed(v, bits): # interpret the low `bits` bits of v as two's complement\n v &= (1 << bits) - 1\n return v - (1 << bits) if v >> (bits - 1) else v\n\n def to_unsigned(v, bits): # the same bits read as unsigned\n return v & ((1 << bits) - 1)\n\nAnd for IEEE-754: `struct.pack('>f', x)` / `struct.unpack('>f', b)` for single precision,\n`'>d'` for double.\n\nPut the requested values in `result` as a list of rows of plain values. Hex strings are always\nlowercase with a `0x` prefix and the full width of the type (e.g. a 32-bit pattern is\n`0x0000002a`, not `0x2a`).\n", "expected_output": "{\"rows\": [[-2147483648, 0]]}"}
|
| {"task_id": "cs-009", "category": "integers", "prompt": "Divide -17 by 4 the way C does for signed ints (truncation toward zero) and the way Python's // does (floor). Return one row [c_result, python_result, c_remainder from -17 % 4 with C semantics].", "api_description": "You are answering machine-level computer-systems questions by COMPUTING the\nanswer in Python, not by recalling it.\n\nAvailable imports: struct, math (nothing else is needed).\n\nPython's integers are unbounded and its `>>` is always an arithmetic shift, so C's fixed-width\nbehaviour must be emulated deliberately. Two helpers you will want:\n\n def to_signed(v, bits): # interpret the low `bits` bits of v as two's complement\n v &= (1 << bits) - 1\n return v - (1 << bits) if v >> (bits - 1) else v\n\n def to_unsigned(v, bits): # the same bits read as unsigned\n return v & ((1 << bits) - 1)\n\nAnd for IEEE-754: `struct.pack('>f', x)` / `struct.unpack('>f', b)` for single precision,\n`'>d'` for double.\n\nPut the requested values in `result` as a list of rows of plain values. Hex strings are always\nlowercase with a `0x` prefix and the full width of the type (e.g. a 32-bit pattern is\n`0x0000002a`, not `0x2a`).\n", "expected_output": "{\"rows\": [[-4, -5, -1]]}"}
|
| {"task_id": "cs-010", "category": "integers", "prompt": "In 16-bit two's complement, add 30000 and 10000 with wrapping, then read the result as unsigned. Return one row [signed result, unsigned result].", "api_description": "You are answering machine-level computer-systems questions by COMPUTING the\nanswer in Python, not by recalling it.\n\nAvailable imports: struct, math (nothing else is needed).\n\nPython's integers are unbounded and its `>>` is always an arithmetic shift, so C's fixed-width\nbehaviour must be emulated deliberately. Two helpers you will want:\n\n def to_signed(v, bits): # interpret the low `bits` bits of v as two's complement\n v &= (1 << bits) - 1\n return v - (1 << bits) if v >> (bits - 1) else v\n\n def to_unsigned(v, bits): # the same bits read as unsigned\n return v & ((1 << bits) - 1)\n\nAnd for IEEE-754: `struct.pack('>f', x)` / `struct.unpack('>f', b)` for single precision,\n`'>d'` for double.\n\nPut the requested values in `result` as a list of rows of plain values. Hex strings are always\nlowercase with a `0x` prefix and the full width of the type (e.g. a 32-bit pattern is\n`0x0000002a`, not `0x2a`).\n", "expected_output": "{\"rows\": [[-25536, 40000]]}"}
|
| {"task_id": "cs-011", "category": "integers", "prompt": "For a 32-bit signed int x = -1, evaluate the C expressions (x >> 31) and ((unsigned)x >> 31). Return one row [arithmetic_shift result as a signed int, logical_shift result as an int].", "api_description": "You are answering machine-level computer-systems questions by COMPUTING the\nanswer in Python, not by recalling it.\n\nAvailable imports: struct, math (nothing else is needed).\n\nPython's integers are unbounded and its `>>` is always an arithmetic shift, so C's fixed-width\nbehaviour must be emulated deliberately. Two helpers you will want:\n\n def to_signed(v, bits): # interpret the low `bits` bits of v as two's complement\n v &= (1 << bits) - 1\n return v - (1 << bits) if v >> (bits - 1) else v\n\n def to_unsigned(v, bits): # the same bits read as unsigned\n return v & ((1 << bits) - 1)\n\nAnd for IEEE-754: `struct.pack('>f', x)` / `struct.unpack('>f', b)` for single precision,\n`'>d'` for double.\n\nPut the requested values in `result` as a list of rows of plain values. Hex strings are always\nlowercase with a `0x` prefix and the full width of the type (e.g. a 32-bit pattern is\n`0x0000002a`, not `0x2a`).\n", "expected_output": "{\"rows\": [[-1, 1]]}"}
|
| {"task_id": "cs-012", "category": "floats", "prompt": "Give the IEEE-754 single-precision (float32) bit pattern of 1.0 and of -2.5 as lowercase hex strings with a '0x' prefix and 8 digits. Return one row [pattern_of_1.0, pattern_of_-2.5].", "api_description": "You are answering machine-level computer-systems questions by COMPUTING the\nanswer in Python, not by recalling it.\n\nAvailable imports: struct, math (nothing else is needed).\n\nPython's integers are unbounded and its `>>` is always an arithmetic shift, so C's fixed-width\nbehaviour must be emulated deliberately. Two helpers you will want:\n\n def to_signed(v, bits): # interpret the low `bits` bits of v as two's complement\n v &= (1 << bits) - 1\n return v - (1 << bits) if v >> (bits - 1) else v\n\n def to_unsigned(v, bits): # the same bits read as unsigned\n return v & ((1 << bits) - 1)\n\nAnd for IEEE-754: `struct.pack('>f', x)` / `struct.unpack('>f', b)` for single precision,\n`'>d'` for double.\n\nPut the requested values in `result` as a list of rows of plain values. Hex strings are always\nlowercase with a `0x` prefix and the full width of the type (e.g. a 32-bit pattern is\n`0x0000002a`, not `0x2a`).\n", "expected_output": "{\"rows\": [[\"0x3f800000\", \"0xc0200000\"]]}"}
|
| {"task_id": "cs-013", "category": "floats", "prompt": "Decode the float32 bit pattern 0x41200000 to its exact value. Return one row [value as a float].", "api_description": "You are answering machine-level computer-systems questions by COMPUTING the\nanswer in Python, not by recalling it.\n\nAvailable imports: struct, math (nothing else is needed).\n\nPython's integers are unbounded and its `>>` is always an arithmetic shift, so C's fixed-width\nbehaviour must be emulated deliberately. Two helpers you will want:\n\n def to_signed(v, bits): # interpret the low `bits` bits of v as two's complement\n v &= (1 << bits) - 1\n return v - (1 << bits) if v >> (bits - 1) else v\n\n def to_unsigned(v, bits): # the same bits read as unsigned\n return v & ((1 << bits) - 1)\n\nAnd for IEEE-754: `struct.pack('>f', x)` / `struct.unpack('>f', b)` for single precision,\n`'>d'` for double.\n\nPut the requested values in `result` as a list of rows of plain values. Hex strings are always\nlowercase with a `0x` prefix and the full width of the type (e.g. a 32-bit pattern is\n`0x0000002a`, not `0x2a`).\n", "expected_output": "{\"rows\": [[10.0]]}"}
|
| {"task_id": "cs-014", "category": "floats", "prompt": "For a float32, give the sign bit, the raw 8-bit exponent field and the 23-bit mantissa field of -6.25, each as an integer. Return one row [sign, exponent_field, mantissa_field].", "api_description": "You are answering machine-level computer-systems questions by COMPUTING the\nanswer in Python, not by recalling it.\n\nAvailable imports: struct, math (nothing else is needed).\n\nPython's integers are unbounded and its `>>` is always an arithmetic shift, so C's fixed-width\nbehaviour must be emulated deliberately. Two helpers you will want:\n\n def to_signed(v, bits): # interpret the low `bits` bits of v as two's complement\n v &= (1 << bits) - 1\n return v - (1 << bits) if v >> (bits - 1) else v\n\n def to_unsigned(v, bits): # the same bits read as unsigned\n return v & ((1 << bits) - 1)\n\nAnd for IEEE-754: `struct.pack('>f', x)` / `struct.unpack('>f', b)` for single precision,\n`'>d'` for double.\n\nPut the requested values in `result` as a list of rows of plain values. Hex strings are always\nlowercase with a `0x` prefix and the full width of the type (e.g. a 32-bit pattern is\n`0x0000002a`, not `0x2a`).\n", "expected_output": "{\"rows\": [[1, 129, 4718592]]}"}
|
| {"task_id": "cs-015", "category": "floats", "prompt": "Round 2**24 + 1 to the nearest float32 and report the result, and whether it equals 2**24. Return one row [rounded value as a float, equals_2_24 as a bool].", "api_description": "You are answering machine-level computer-systems questions by COMPUTING the\nanswer in Python, not by recalling it.\n\nAvailable imports: struct, math (nothing else is needed).\n\nPython's integers are unbounded and its `>>` is always an arithmetic shift, so C's fixed-width\nbehaviour must be emulated deliberately. Two helpers you will want:\n\n def to_signed(v, bits): # interpret the low `bits` bits of v as two's complement\n v &= (1 << bits) - 1\n return v - (1 << bits) if v >> (bits - 1) else v\n\n def to_unsigned(v, bits): # the same bits read as unsigned\n return v & ((1 << bits) - 1)\n\nAnd for IEEE-754: `struct.pack('>f', x)` / `struct.unpack('>f', b)` for single precision,\n`'>d'` for double.\n\nPut the requested values in `result` as a list of rows of plain values. Hex strings are always\nlowercase with a `0x` prefix and the full width of the type (e.g. a 32-bit pattern is\n`0x0000002a`, not `0x2a`).\n", "expected_output": "{\"rows\": [[16777216.0, true]]}"}
|
| {"task_id": "cs-016", "category": "floats", "prompt": "Float32 addition is not associative. With a = 1e8, b = -1e8 and c = 1.0, compute (a + b) + c and a + (b + c), rounding through float32 after EVERY operation. Return one row [left_assoc, right_assoc, they_differ as a bool].", "api_description": "You are answering machine-level computer-systems questions by COMPUTING the\nanswer in Python, not by recalling it.\n\nAvailable imports: struct, math (nothing else is needed).\n\nPython's integers are unbounded and its `>>` is always an arithmetic shift, so C's fixed-width\nbehaviour must be emulated deliberately. Two helpers you will want:\n\n def to_signed(v, bits): # interpret the low `bits` bits of v as two's complement\n v &= (1 << bits) - 1\n return v - (1 << bits) if v >> (bits - 1) else v\n\n def to_unsigned(v, bits): # the same bits read as unsigned\n return v & ((1 << bits) - 1)\n\nAnd for IEEE-754: `struct.pack('>f', x)` / `struct.unpack('>f', b)` for single precision,\n`'>d'` for double.\n\nPut the requested values in `result` as a list of rows of plain values. Hex strings are always\nlowercase with a `0x` prefix and the full width of the type (e.g. a 32-bit pattern is\n`0x0000002a`, not `0x2a`).\n", "expected_output": "{\"rows\": [[1.0, 0.0, true]]}"}
|
| {"task_id": "cs-017", "category": "floats", "prompt": "In double precision, is 0.1 + 0.2 exactly 0.3? Also give the exact double value of 0.1 + 0.2 rendered by repr, and the bit pattern of 0.1 as a 16-digit lowercase hex string with a '0x' prefix. Return one row [equal as a bool, sum_repr as a string, bits_of_0.1].", "api_description": "You are answering machine-level computer-systems questions by COMPUTING the\nanswer in Python, not by recalling it.\n\nAvailable imports: struct, math (nothing else is needed).\n\nPython's integers are unbounded and its `>>` is always an arithmetic shift, so C's fixed-width\nbehaviour must be emulated deliberately. Two helpers you will want:\n\n def to_signed(v, bits): # interpret the low `bits` bits of v as two's complement\n v &= (1 << bits) - 1\n return v - (1 << bits) if v >> (bits - 1) else v\n\n def to_unsigned(v, bits): # the same bits read as unsigned\n return v & ((1 << bits) - 1)\n\nAnd for IEEE-754: `struct.pack('>f', x)` / `struct.unpack('>f', b)` for single precision,\n`'>d'` for double.\n\nPut the requested values in `result` as a list of rows of plain values. Hex strings are always\nlowercase with a `0x` prefix and the full width of the type (e.g. a 32-bit pattern is\n`0x0000002a`, not `0x2a`).\n", "expected_output": "{\"rows\": [[false, \"0.30000000000000004\", \"0x3fb999999999999a\"]]}"}
|
| {"task_id": "cs-018", "category": "floats", "prompt": "Give the smallest positive NORMAL float32 and the smallest positive DENORMAL (subnormal) float32, each decoded from its bit pattern. Return one row [smallest_normal, smallest_denormal].", "api_description": "You are answering machine-level computer-systems questions by COMPUTING the\nanswer in Python, not by recalling it.\n\nAvailable imports: struct, math (nothing else is needed).\n\nPython's integers are unbounded and its `>>` is always an arithmetic shift, so C's fixed-width\nbehaviour must be emulated deliberately. Two helpers you will want:\n\n def to_signed(v, bits): # interpret the low `bits` bits of v as two's complement\n v &= (1 << bits) - 1\n return v - (1 << bits) if v >> (bits - 1) else v\n\n def to_unsigned(v, bits): # the same bits read as unsigned\n return v & ((1 << bits) - 1)\n\nAnd for IEEE-754: `struct.pack('>f', x)` / `struct.unpack('>f', b)` for single precision,\n`'>d'` for double.\n\nPut the requested values in `result` as a list of rows of plain values. Hex strings are always\nlowercase with a `0x` prefix and the full width of the type (e.g. a 32-bit pattern is\n`0x0000002a`, not `0x2a`).\n", "expected_output": "{\"rows\": [[1.1754943508222875e-38, 1.401298464324817e-45]]}"}
|
| {"task_id": "cs-019", "category": "floats", "prompt": "Decode the float32 bit patterns 0x7f800000, 0xff800000 and 0x7fc00000, and report each as a string via repr. Return one row [repr of the first, repr of the second, repr of the third].", "api_description": "You are answering machine-level computer-systems questions by COMPUTING the\nanswer in Python, not by recalling it.\n\nAvailable imports: struct, math (nothing else is needed).\n\nPython's integers are unbounded and its `>>` is always an arithmetic shift, so C's fixed-width\nbehaviour must be emulated deliberately. Two helpers you will want:\n\n def to_signed(v, bits): # interpret the low `bits` bits of v as two's complement\n v &= (1 << bits) - 1\n return v - (1 << bits) if v >> (bits - 1) else v\n\n def to_unsigned(v, bits): # the same bits read as unsigned\n return v & ((1 << bits) - 1)\n\nAnd for IEEE-754: `struct.pack('>f', x)` / `struct.unpack('>f', b)` for single precision,\n`'>d'` for double.\n\nPut the requested values in `result` as a list of rows of plain values. Hex strings are always\nlowercase with a `0x` prefix and the full width of the type (e.g. a 32-bit pattern is\n`0x0000002a`, not `0x2a`).\n", "expected_output": "{\"rows\": [[\"inf\", \"-inf\", \"nan\"]]}"}
|
| {"task_id": "cs-020", "category": "floats", "prompt": "The integer 16777217 is converted to float32 and back to an integer. Report the round-tripped integer and whether it differs from the original. Return one row [round_tripped, differs as a bool].", "api_description": "You are answering machine-level computer-systems questions by COMPUTING the\nanswer in Python, not by recalling it.\n\nAvailable imports: struct, math (nothing else is needed).\n\nPython's integers are unbounded and its `>>` is always an arithmetic shift, so C's fixed-width\nbehaviour must be emulated deliberately. Two helpers you will want:\n\n def to_signed(v, bits): # interpret the low `bits` bits of v as two's complement\n v &= (1 << bits) - 1\n return v - (1 << bits) if v >> (bits - 1) else v\n\n def to_unsigned(v, bits): # the same bits read as unsigned\n return v & ((1 << bits) - 1)\n\nAnd for IEEE-754: `struct.pack('>f', x)` / `struct.unpack('>f', b)` for single precision,\n`'>d'` for double.\n\nPut the requested values in `result` as a list of rows of plain values. Hex strings are always\nlowercase with a `0x` prefix and the full width of the type (e.g. a 32-bit pattern is\n`0x0000002a`, not `0x2a`).\n", "expected_output": "{\"rows\": [[16777216, true]]}"}
|
| {"task_id": "cs-021", "category": "floats", "prompt": "Compute, in float32, the value of 0.1 + 0.2 and its bit pattern as an 8-digit lowercase hex string with a '0x' prefix, rounding through float32 after the addition. Return one row [value, pattern].", "api_description": "You are answering machine-level computer-systems questions by COMPUTING the\nanswer in Python, not by recalling it.\n\nAvailable imports: struct, math (nothing else is needed).\n\nPython's integers are unbounded and its `>>` is always an arithmetic shift, so C's fixed-width\nbehaviour must be emulated deliberately. Two helpers you will want:\n\n def to_signed(v, bits): # interpret the low `bits` bits of v as two's complement\n v &= (1 << bits) - 1\n return v - (1 << bits) if v >> (bits - 1) else v\n\n def to_unsigned(v, bits): # the same bits read as unsigned\n return v & ((1 << bits) - 1)\n\nAnd for IEEE-754: `struct.pack('>f', x)` / `struct.unpack('>f', b)` for single precision,\n`'>d'` for double.\n\nPut the requested values in `result` as a list of rows of plain values. Hex strings are always\nlowercase with a `0x` prefix and the full width of the type (e.g. a 32-bit pattern is\n`0x0000002a`, not `0x2a`).\n", "expected_output": "{\"rows\": [[0.30000001192092896, \"0x3e99999a\"]]}"}
|
| {"task_id": "cs-022", "category": "bits", "prompt": "For the 32-bit value 0x0000ff00, isolate the lowest set bit and clear the lowest set bit, using the classic x & -x and x & (x - 1) identities under 32-bit wrapping. Return one row [lowest_set_bit, cleared as ints].", "api_description": "You are answering machine-level computer-systems questions by COMPUTING the\nanswer in Python, not by recalling it.\n\nAvailable imports: struct, math (nothing else is needed).\n\nPython's integers are unbounded and its `>>` is always an arithmetic shift, so C's fixed-width\nbehaviour must be emulated deliberately. Two helpers you will want:\n\n def to_signed(v, bits): # interpret the low `bits` bits of v as two's complement\n v &= (1 << bits) - 1\n return v - (1 << bits) if v >> (bits - 1) else v\n\n def to_unsigned(v, bits): # the same bits read as unsigned\n return v & ((1 << bits) - 1)\n\nAnd for IEEE-754: `struct.pack('>f', x)` / `struct.unpack('>f', b)` for single precision,\n`'>d'` for double.\n\nPut the requested values in `result` as a list of rows of plain values. Hex strings are always\nlowercase with a `0x` prefix and the full width of the type (e.g. a 32-bit pattern is\n`0x0000002a`, not `0x2a`).\n", "expected_output": "{\"rows\": [[256, 65024]]}"}
|
| {"task_id": "cs-023", "category": "bits", "prompt": "Count the set bits in the 32-bit patterns of 0x0f0f0f0f and of -1. Return one row [popcount_first, popcount_second].", "api_description": "You are answering machine-level computer-systems questions by COMPUTING the\nanswer in Python, not by recalling it.\n\nAvailable imports: struct, math (nothing else is needed).\n\nPython's integers are unbounded and its `>>` is always an arithmetic shift, so C's fixed-width\nbehaviour must be emulated deliberately. Two helpers you will want:\n\n def to_signed(v, bits): # interpret the low `bits` bits of v as two's complement\n v &= (1 << bits) - 1\n return v - (1 << bits) if v >> (bits - 1) else v\n\n def to_unsigned(v, bits): # the same bits read as unsigned\n return v & ((1 << bits) - 1)\n\nAnd for IEEE-754: `struct.pack('>f', x)` / `struct.unpack('>f', b)` for single precision,\n`'>d'` for double.\n\nPut the requested values in `result` as a list of rows of plain values. Hex strings are always\nlowercase with a `0x` prefix and the full width of the type (e.g. a 32-bit pattern is\n`0x0000002a`, not `0x2a`).\n", "expected_output": "{\"rows\": [[16, 32]]}"}
|
| {"task_id": "cs-024", "category": "bits", "prompt": "Reverse the byte order of the 32-bit value 0x12345678 (a 32-bit byte swap). Return one row [swapped as an 8-digit lowercase hex string with a '0x' prefix].", "api_description": "You are answering machine-level computer-systems questions by COMPUTING the\nanswer in Python, not by recalling it.\n\nAvailable imports: struct, math (nothing else is needed).\n\nPython's integers are unbounded and its `>>` is always an arithmetic shift, so C's fixed-width\nbehaviour must be emulated deliberately. Two helpers you will want:\n\n def to_signed(v, bits): # interpret the low `bits` bits of v as two's complement\n v &= (1 << bits) - 1\n return v - (1 << bits) if v >> (bits - 1) else v\n\n def to_unsigned(v, bits): # the same bits read as unsigned\n return v & ((1 << bits) - 1)\n\nAnd for IEEE-754: `struct.pack('>f', x)` / `struct.unpack('>f', b)` for single precision,\n`'>d'` for double.\n\nPut the requested values in `result` as a list of rows of plain values. Hex strings are always\nlowercase with a `0x` prefix and the full width of the type (e.g. a 32-bit pattern is\n`0x0000002a`, not `0x2a`).\n", "expected_output": "{\"rows\": [[\"0x78563412\"]]}"}
|
| {"task_id": "cs-025", "category": "bits", "prompt": "For the 32-bit value 0x000000a5, compute a rotate-left by 4 and a rotate-right by 4 (rotations, not shifts). Return one row [rotl4, rotr4 as 8-digit lowercase hex strings with a '0x' prefix].", "api_description": "You are answering machine-level computer-systems questions by COMPUTING the\nanswer in Python, not by recalling it.\n\nAvailable imports: struct, math (nothing else is needed).\n\nPython's integers are unbounded and its `>>` is always an arithmetic shift, so C's fixed-width\nbehaviour must be emulated deliberately. Two helpers you will want:\n\n def to_signed(v, bits): # interpret the low `bits` bits of v as two's complement\n v &= (1 << bits) - 1\n return v - (1 << bits) if v >> (bits - 1) else v\n\n def to_unsigned(v, bits): # the same bits read as unsigned\n return v & ((1 << bits) - 1)\n\nAnd for IEEE-754: `struct.pack('>f', x)` / `struct.unpack('>f', b)` for single precision,\n`'>d'` for double.\n\nPut the requested values in `result` as a list of rows of plain values. Hex strings are always\nlowercase with a `0x` prefix and the full width of the type (e.g. a 32-bit pattern is\n`0x0000002a`, not `0x2a`).\n", "expected_output": "{\"rows\": [[\"0x00000a50\", \"0x5000000a\"]]}"}
|
| {"task_id": "cs-026", "category": "bits", "prompt": "Extract bits 8 through 15 inclusive (a byte field) from the 32-bit value 0xdeadbeef, as an integer, and give the value with that field cleared to zero. Return one row [field, cleared as an 8-digit lowercase hex string with a '0x' prefix].", "api_description": "You are answering machine-level computer-systems questions by COMPUTING the\nanswer in Python, not by recalling it.\n\nAvailable imports: struct, math (nothing else is needed).\n\nPython's integers are unbounded and its `>>` is always an arithmetic shift, so C's fixed-width\nbehaviour must be emulated deliberately. Two helpers you will want:\n\n def to_signed(v, bits): # interpret the low `bits` bits of v as two's complement\n v &= (1 << bits) - 1\n return v - (1 << bits) if v >> (bits - 1) else v\n\n def to_unsigned(v, bits): # the same bits read as unsigned\n return v & ((1 << bits) - 1)\n\nAnd for IEEE-754: `struct.pack('>f', x)` / `struct.unpack('>f', b)` for single precision,\n`'>d'` for double.\n\nPut the requested values in `result` as a list of rows of plain values. Hex strings are always\nlowercase with a `0x` prefix and the full width of the type (e.g. a 32-bit pattern is\n`0x0000002a`, not `0x2a`).\n", "expected_output": "{\"rows\": [[190, \"0xdead00ef\"]]}"}
|
| {"task_id": "cs-027", "category": "bits", "prompt": "Compute the 32-bit XOR of 0xaaaaaaaa and 0x55555555, and the 32-bit value of ~0x0000ffff. Return one row [xor, complement as 8-digit lowercase hex strings with a '0x' prefix].", "api_description": "You are answering machine-level computer-systems questions by COMPUTING the\nanswer in Python, not by recalling it.\n\nAvailable imports: struct, math (nothing else is needed).\n\nPython's integers are unbounded and its `>>` is always an arithmetic shift, so C's fixed-width\nbehaviour must be emulated deliberately. Two helpers you will want:\n\n def to_signed(v, bits): # interpret the low `bits` bits of v as two's complement\n v &= (1 << bits) - 1\n return v - (1 << bits) if v >> (bits - 1) else v\n\n def to_unsigned(v, bits): # the same bits read as unsigned\n return v & ((1 << bits) - 1)\n\nAnd for IEEE-754: `struct.pack('>f', x)` / `struct.unpack('>f', b)` for single precision,\n`'>d'` for double.\n\nPut the requested values in `result` as a list of rows of plain values. Hex strings are always\nlowercase with a `0x` prefix and the full width of the type (e.g. a 32-bit pattern is\n`0x0000002a`, not `0x2a`).\n", "expected_output": "{\"rows\": [[\"0xffffffff\", \"0xffff0000\"]]}"}
|
| {"task_id": "cs-028", "category": "memory", "prompt": "The 32-bit integer 0x01020304 is stored at an address. List its four bytes in memory order on a LITTLE-endian machine and on a BIG-endian machine. Return two rows: the little-endian bytes as four ints, then the big-endian bytes as four ints.", "api_description": "You are answering machine-level computer-systems questions by COMPUTING the\nanswer in Python, not by recalling it.\n\nAvailable imports: struct, math (nothing else is needed).\n\nPython's integers are unbounded and its `>>` is always an arithmetic shift, so C's fixed-width\nbehaviour must be emulated deliberately. Two helpers you will want:\n\n def to_signed(v, bits): # interpret the low `bits` bits of v as two's complement\n v &= (1 << bits) - 1\n return v - (1 << bits) if v >> (bits - 1) else v\n\n def to_unsigned(v, bits): # the same bits read as unsigned\n return v & ((1 << bits) - 1)\n\nAnd for IEEE-754: `struct.pack('>f', x)` / `struct.unpack('>f', b)` for single precision,\n`'>d'` for double.\n\nPut the requested values in `result` as a list of rows of plain values. Hex strings are always\nlowercase with a `0x` prefix and the full width of the type (e.g. a 32-bit pattern is\n`0x0000002a`, not `0x2a`).\n", "expected_output": "{\"rows\": [[4, 3, 2, 1], [1, 2, 3, 4]]}"}
|
| {"task_id": "cs-029", "category": "memory", "prompt": "A C struct is { char a; int b; char c; } with 4-byte alignment for int and 1-byte for char. Give the byte offset of each member and the total size including trailing padding. Return one row [offset_a, offset_b, offset_c, sizeof].", "api_description": "You are answering machine-level computer-systems questions by COMPUTING the\nanswer in Python, not by recalling it.\n\nAvailable imports: struct, math (nothing else is needed).\n\nPython's integers are unbounded and its `>>` is always an arithmetic shift, so C's fixed-width\nbehaviour must be emulated deliberately. Two helpers you will want:\n\n def to_signed(v, bits): # interpret the low `bits` bits of v as two's complement\n v &= (1 << bits) - 1\n return v - (1 << bits) if v >> (bits - 1) else v\n\n def to_unsigned(v, bits): # the same bits read as unsigned\n return v & ((1 << bits) - 1)\n\nAnd for IEEE-754: `struct.pack('>f', x)` / `struct.unpack('>f', b)` for single precision,\n`'>d'` for double.\n\nPut the requested values in `result` as a list of rows of plain values. Hex strings are always\nlowercase with a `0x` prefix and the full width of the type (e.g. a 32-bit pattern is\n`0x0000002a`, not `0x2a`).\n", "expected_output": "{\"rows\": [[0, 4, 8, 12]]}"}
|
| {"task_id": "cs-030", "category": "memory", "prompt": "The same three members reordered as { int b; char a; char c; }. Give each offset and the total size including trailing padding, with the same alignment rules. Return one row [offset_b, offset_a, offset_c, sizeof].", "api_description": "You are answering machine-level computer-systems questions by COMPUTING the\nanswer in Python, not by recalling it.\n\nAvailable imports: struct, math (nothing else is needed).\n\nPython's integers are unbounded and its `>>` is always an arithmetic shift, so C's fixed-width\nbehaviour must be emulated deliberately. Two helpers you will want:\n\n def to_signed(v, bits): # interpret the low `bits` bits of v as two's complement\n v &= (1 << bits) - 1\n return v - (1 << bits) if v >> (bits - 1) else v\n\n def to_unsigned(v, bits): # the same bits read as unsigned\n return v & ((1 << bits) - 1)\n\nAnd for IEEE-754: `struct.pack('>f', x)` / `struct.unpack('>f', b)` for single precision,\n`'>d'` for double.\n\nPut the requested values in `result` as a list of rows of plain values. Hex strings are always\nlowercase with a `0x` prefix and the full width of the type (e.g. a 32-bit pattern is\n`0x0000002a`, not `0x2a`).\n", "expected_output": "{\"rows\": [[0, 4, 5, 8]]}"}
|
| {"task_id": "cs-031", "category": "memory", "prompt": "Interpret the four bytes 0xff 0xff 0xff 0xff as a little-endian 32-bit signed int and as an unsigned int. Return one row [signed, unsigned].", "api_description": "You are answering machine-level computer-systems questions by COMPUTING the\nanswer in Python, not by recalling it.\n\nAvailable imports: struct, math (nothing else is needed).\n\nPython's integers are unbounded and its `>>` is always an arithmetic shift, so C's fixed-width\nbehaviour must be emulated deliberately. Two helpers you will want:\n\n def to_signed(v, bits): # interpret the low `bits` bits of v as two's complement\n v &= (1 << bits) - 1\n return v - (1 << bits) if v >> (bits - 1) else v\n\n def to_unsigned(v, bits): # the same bits read as unsigned\n return v & ((1 << bits) - 1)\n\nAnd for IEEE-754: `struct.pack('>f', x)` / `struct.unpack('>f', b)` for single precision,\n`'>d'` for double.\n\nPut the requested values in `result` as a list of rows of plain values. Hex strings are always\nlowercase with a `0x` prefix and the full width of the type (e.g. a 32-bit pattern is\n`0x0000002a`, not `0x2a`).\n", "expected_output": "{\"rows\": [[-1, 4294967295]]}"}
|
| {"task_id": "cs-032", "category": "memory", "prompt": "Given an array `int a[10]` starting at address 0x1000 with 4-byte ints, give the addresses of a[0], a[3] and a[9] as 4-digit lowercase hex strings with a '0x' prefix. Return one row [addr0, addr3, addr9].", "api_description": "You are answering machine-level computer-systems questions by COMPUTING the\nanswer in Python, not by recalling it.\n\nAvailable imports: struct, math (nothing else is needed).\n\nPython's integers are unbounded and its `>>` is always an arithmetic shift, so C's fixed-width\nbehaviour must be emulated deliberately. Two helpers you will want:\n\n def to_signed(v, bits): # interpret the low `bits` bits of v as two's complement\n v &= (1 << bits) - 1\n return v - (1 << bits) if v >> (bits - 1) else v\n\n def to_unsigned(v, bits): # the same bits read as unsigned\n return v & ((1 << bits) - 1)\n\nAnd for IEEE-754: `struct.pack('>f', x)` / `struct.unpack('>f', b)` for single precision,\n`'>d'` for double.\n\nPut the requested values in `result` as a list of rows of plain values. Hex strings are always\nlowercase with a `0x` prefix and the full width of the type (e.g. a 32-bit pattern is\n`0x0000002a`, not `0x2a`).\n", "expected_output": "{\"rows\": [[\"0x1000\", \"0x100c\", \"0x1024\"]]}"}
|
| {"task_id": "cs-033", "category": "memory", "prompt": "The bytes 0x40 0x49 0x0f 0xdb are stored in BIG-endian order and read as a float32. Give the value, and give the value if the same four bytes are read LITTLE-endian instead. Return one row [big_endian_value, little_endian_value].", "api_description": "You are answering machine-level computer-systems questions by COMPUTING the\nanswer in Python, not by recalling it.\n\nAvailable imports: struct, math (nothing else is needed).\n\nPython's integers are unbounded and its `>>` is always an arithmetic shift, so C's fixed-width\nbehaviour must be emulated deliberately. Two helpers you will want:\n\n def to_signed(v, bits): # interpret the low `bits` bits of v as two's complement\n v &= (1 << bits) - 1\n return v - (1 << bits) if v >> (bits - 1) else v\n\n def to_unsigned(v, bits): # the same bits read as unsigned\n return v & ((1 << bits) - 1)\n\nAnd for IEEE-754: `struct.pack('>f', x)` / `struct.unpack('>f', b)` for single precision,\n`'>d'` for double.\n\nPut the requested values in `result` as a list of rows of plain values. Hex strings are always\nlowercase with a `0x` prefix and the full width of the type (e.g. a 32-bit pattern is\n`0x0000002a`, not `0x2a`).\n", "expected_output": "{\"rows\": [[3.1415927410125732, -4.03314608963584e+16]]}"}
|
| {"task_id": "cs-034", "category": "cache", "prompt": "A direct-mapped cache has 64 sets and 16-byte blocks, with 32-bit addresses. Decompose the address 0x00001834 into its block offset, set index and tag (as integers). Return one row [offset, set_index, tag].", "api_description": "You are answering machine-level computer-systems questions by COMPUTING the\nanswer in Python, not by recalling it.\n\nAvailable imports: struct, math (nothing else is needed).\n\nPython's integers are unbounded and its `>>` is always an arithmetic shift, so C's fixed-width\nbehaviour must be emulated deliberately. Two helpers you will want:\n\n def to_signed(v, bits): # interpret the low `bits` bits of v as two's complement\n v &= (1 << bits) - 1\n return v - (1 << bits) if v >> (bits - 1) else v\n\n def to_unsigned(v, bits): # the same bits read as unsigned\n return v & ((1 << bits) - 1)\n\nAnd for IEEE-754: `struct.pack('>f', x)` / `struct.unpack('>f', b)` for single precision,\n`'>d'` for double.\n\nPut the requested values in `result` as a list of rows of plain values. Hex strings are always\nlowercase with a `0x` prefix and the full width of the type (e.g. a 32-bit pattern is\n`0x0000002a`, not `0x2a`).\n", "expected_output": "{\"rows\": [[4, 3, 6]]}"}
|
| {"task_id": "cs-035", "category": "cache", "prompt": "Same cache: 64 sets, 16-byte blocks, direct-mapped, 32-bit addresses. Give the number of offset bits, index bits and tag bits. Return one row [offset_bits, index_bits, tag_bits].", "api_description": "You are answering machine-level computer-systems questions by COMPUTING the\nanswer in Python, not by recalling it.\n\nAvailable imports: struct, math (nothing else is needed).\n\nPython's integers are unbounded and its `>>` is always an arithmetic shift, so C's fixed-width\nbehaviour must be emulated deliberately. Two helpers you will want:\n\n def to_signed(v, bits): # interpret the low `bits` bits of v as two's complement\n v &= (1 << bits) - 1\n return v - (1 << bits) if v >> (bits - 1) else v\n\n def to_unsigned(v, bits): # the same bits read as unsigned\n return v & ((1 << bits) - 1)\n\nAnd for IEEE-754: `struct.pack('>f', x)` / `struct.unpack('>f', b)` for single precision,\n`'>d'` for double.\n\nPut the requested values in `result` as a list of rows of plain values. Hex strings are always\nlowercase with a `0x` prefix and the full width of the type (e.g. a 32-bit pattern is\n`0x0000002a`, not `0x2a`).\n", "expected_output": "{\"rows\": [[4, 6, 22]]}"}
|
| {"task_id": "cs-036", "category": "cache", "prompt": "A 2-way set-associative cache holds 8 KiB of data with 32-byte blocks. Give the number of blocks, the number of sets, and the number of index bits. Return one row [blocks, sets, index_bits].", "api_description": "You are answering machine-level computer-systems questions by COMPUTING the\nanswer in Python, not by recalling it.\n\nAvailable imports: struct, math (nothing else is needed).\n\nPython's integers are unbounded and its `>>` is always an arithmetic shift, so C's fixed-width\nbehaviour must be emulated deliberately. Two helpers you will want:\n\n def to_signed(v, bits): # interpret the low `bits` bits of v as two's complement\n v &= (1 << bits) - 1\n return v - (1 << bits) if v >> (bits - 1) else v\n\n def to_unsigned(v, bits): # the same bits read as unsigned\n return v & ((1 << bits) - 1)\n\nAnd for IEEE-754: `struct.pack('>f', x)` / `struct.unpack('>f', b)` for single precision,\n`'>d'` for double.\n\nPut the requested values in `result` as a list of rows of plain values. Hex strings are always\nlowercase with a `0x` prefix and the full width of the type (e.g. a 32-bit pattern is\n`0x0000002a`, not `0x2a`).\n", "expected_output": "{\"rows\": [[256, 128, 7]]}"}
|
| {"task_id": "cs-037", "category": "cache", "prompt": "A direct-mapped cache has 4 sets and 16-byte blocks, initially empty. The addresses 0, 16, 0, 64, 0 are accessed in that order. For each access report 1 for a hit and 0 for a miss. Return one row of five values, in order.", "api_description": "You are answering machine-level computer-systems questions by COMPUTING the\nanswer in Python, not by recalling it.\n\nAvailable imports: struct, math (nothing else is needed).\n\nPython's integers are unbounded and its `>>` is always an arithmetic shift, so C's fixed-width\nbehaviour must be emulated deliberately. Two helpers you will want:\n\n def to_signed(v, bits): # interpret the low `bits` bits of v as two's complement\n v &= (1 << bits) - 1\n return v - (1 << bits) if v >> (bits - 1) else v\n\n def to_unsigned(v, bits): # the same bits read as unsigned\n return v & ((1 << bits) - 1)\n\nAnd for IEEE-754: `struct.pack('>f', x)` / `struct.unpack('>f', b)` for single precision,\n`'>d'` for double.\n\nPut the requested values in `result` as a list of rows of plain values. Hex strings are always\nlowercase with a `0x` prefix and the full width of the type (e.g. a 32-bit pattern is\n`0x0000002a`, not `0x2a`).\n", "expected_output": "{\"rows\": [[0, 0, 1, 0, 0]]}"}
|
| {"task_id": "cs-038", "category": "cache", "prompt": "A fully-associative cache holds 4 blocks of 8 bytes and evicts least-recently used. The addresses 0, 8, 16, 24, 0, 32, 8 are accessed in that order. Report 1 for a hit and 0 for a miss for each. Return one row of seven values, in order.", "api_description": "You are answering machine-level computer-systems questions by COMPUTING the\nanswer in Python, not by recalling it.\n\nAvailable imports: struct, math (nothing else is needed).\n\nPython's integers are unbounded and its `>>` is always an arithmetic shift, so C's fixed-width\nbehaviour must be emulated deliberately. Two helpers you will want:\n\n def to_signed(v, bits): # interpret the low `bits` bits of v as two's complement\n v &= (1 << bits) - 1\n return v - (1 << bits) if v >> (bits - 1) else v\n\n def to_unsigned(v, bits): # the same bits read as unsigned\n return v & ((1 << bits) - 1)\n\nAnd for IEEE-754: `struct.pack('>f', x)` / `struct.unpack('>f', b)` for single precision,\n`'>d'` for double.\n\nPut the requested values in `result` as a list of rows of plain values. Hex strings are always\nlowercase with a `0x` prefix and the full width of the type (e.g. a 32-bit pattern is\n`0x0000002a`, not `0x2a`).\n", "expected_output": "{\"rows\": [[0, 0, 0, 0, 1, 0, 0]]}"}
|
| {"task_id": "cs-039", "category": "cache", "prompt": "An `int a[4][8]` of 4-byte ints starts at address 0. The cache is DIRECT-MAPPED with 2 sets and 16-byte blocks — far smaller than the array. Count the total misses when every element is read in ROW-major order (i outer, j inner) and in COLUMN-major order (j outer, i inner). Return one row [row_major_misses, column_major_misses].", "api_description": "You are answering machine-level computer-systems questions by COMPUTING the\nanswer in Python, not by recalling it.\n\nAvailable imports: struct, math (nothing else is needed).\n\nPython's integers are unbounded and its `>>` is always an arithmetic shift, so C's fixed-width\nbehaviour must be emulated deliberately. Two helpers you will want:\n\n def to_signed(v, bits): # interpret the low `bits` bits of v as two's complement\n v &= (1 << bits) - 1\n return v - (1 << bits) if v >> (bits - 1) else v\n\n def to_unsigned(v, bits): # the same bits read as unsigned\n return v & ((1 << bits) - 1)\n\nAnd for IEEE-754: `struct.pack('>f', x)` / `struct.unpack('>f', b)` for single precision,\n`'>d'` for double.\n\nPut the requested values in `result` as a list of rows of plain values. Hex strings are always\nlowercase with a `0x` prefix and the full width of the type (e.g. a 32-bit pattern is\n`0x0000002a`, not `0x2a`).\n", "expected_output": "{\"rows\": [[8, 32]]}"}
|
|
|