This commit is contained in:
krahets
2024-05-06 14:40:42 +08:00
parent 3572f39b25
commit 885877f818
62 changed files with 3815 additions and 574 deletions

View File

@@ -3603,7 +3603,7 @@
<li><strong>One's complement</strong>: The one's complement of a positive number is the same as its sign-magnitude. For negative numbers, it's obtained by inverting all bits except the sign bit.</li>
<li><strong>Two's complement</strong>: The two's complement of a positive number is the same as its sign-magnitude. For negative numbers, it's obtained by adding <span class="arithmatex">\(1\)</span> to their one's complement.</li>
</ul>
<p>The following diagram illustrates the conversions among sign-magnitude, one's complement, and two's complement:</p>
<p>Figure 3-4 illustrates the conversions among sign-magnitude, one's complement, and two's complement:</p>
<p><a class="glightbox" href="../number_encoding.assets/1s_2s_complement.png" data-type="image" data-width="100%" data-height="auto" data-desc-position="bottom"><img alt="Conversions between sign-magnitude, one's complement, and two's complement" class="animation-figure" src="../number_encoding.assets/1s_2s_complement.png" /></a></p>
<p align="center"> Figure 3-4 &nbsp; Conversions between sign-magnitude, one's complement, and two's complement </p>
@@ -3689,7 +3689,7 @@ b_{31} b_{30} b_{29} \ldots b_2 b_1 b_0
<p><a class="glightbox" href="../number_encoding.assets/ieee_754_float.png" data-type="image" data-width="100%" data-height="auto" data-desc-position="bottom"><img alt="Example calculation of a float in IEEE 754 standard" class="animation-figure" src="../number_encoding.assets/ieee_754_float.png" /></a></p>
<p align="center"> Figure 3-5 &nbsp; Example calculation of a float in IEEE 754 standard </p>
<p>Observing the diagram, given an example data <span class="arithmatex">\(\mathrm{S} = 0\)</span>, <span class="arithmatex">\(\mathrm{E} = 124\)</span>, <span class="arithmatex">\(\mathrm{N} = 2^{-2} + 2^{-3} = 0.375\)</span>, we have:</p>
<p>Observing Figure 3-5, given an example data <span class="arithmatex">\(\mathrm{S} = 0\)</span>, <span class="arithmatex">\(\mathrm{E} = 124\)</span>, <span class="arithmatex">\(\mathrm{N} = 2^{-2} + 2^{-3} = 0.375\)</span>, we have:</p>
<div class="arithmatex">\[
\text{val} = (-1)^0 \times 2^{124 - 127} \times (1 + 0.375) = 0.171875
\]</div>