5 lines
1.3 KiB
HTML
5 lines
1.3 KiB
HTML
<!doctype html><html lang="en"><meta charset="utf-8"><title>Bits, bytes, and integer width</title><h1>Bits, bytes, and integer width</h1><p>15-minute session: read for 3 minutes, trace for 3, experiment for 7, and complete the check for 2. Spend longer whenever you need.</p><p>Eight bits represent 256 bit patterns. Unsigned 8-bit values range from 0 to 255. The model uses modulo arithmetic to wrap 256 to zero; Python integers do not naturally have this fixed width. Compare signed and unsigned interpretations of 255. Predict the range for 16 bits. Do not infer pointer size or a language’s integer size solely from a CPU’s marketing name.</p><pre><code class="language-python">bits=8
|
||
print(2**bits)
|
||
print((255+1) % (2**bits))
|
||
</code></pre><p><strong>Expected result:</strong> <code>256
|
||
0</code></p><h3>Practice and evidence</h3><p>Keep three notes: your prediction, the actual result, and why they match or differ. The completion check grades understanding; the practice task builds skill.</p><p><a href="https://www.intel.com/content/www/us/en/developer/articles/technical/intel-sdm.html">Language reference: www.intel.com</a></p><p><a href="https://developer.arm.com/Architectures/Learn%20the%20Architecture">Language reference: developer.arm.com</a></p><p><a href="https://docs.riscv.org/">Language reference: docs.riscv.org</a></p></html> |