This commit is contained in:
krahets
2026-04-04 23:10:58 +08:00
parent 5b59dbded2
commit fec71ace08
168 changed files with 308 additions and 963 deletions
+3 -3
View File
@@ -1665,7 +1665,7 @@
<span class="md-ellipsis">
Chapter 6. Hash Table
Chapter 6. Hashing
@@ -1687,7 +1687,7 @@
<span class="md-nav__icon md-icon"></span>
Chapter 6. Hash Table
Chapter 6. Hashing
</label>
@@ -4397,7 +4397,7 @@
1110 \rightarrow 1101 \rightarrow 0010
\]</div>
<p>In summary, both "first negate then add 1" and "first subtract 1 then negate" are computing the complement to <span class="arithmatex">\(10000\)</span>, and they are equivalent.</p>
<p>Essentially, the "negate" operation is actually finding the complement to <span class="arithmatex">\(1111\)</span> (because <code>sign-magnitude + 1's complement = 1111</code> always holds); and adding 1 to the 1's complement yields the 2's complement, which is the complement to <span class="arithmatex">\(10000\)</span>.</p>
<p>Essentially, the "negate" operation is actually finding the complement to <span class="arithmatex">\(1111\)</span> (because "sign-magnitude + 1's complement = 1111" always holds); and adding 1 to the 1's complement yields the 2's complement, which is the complement to <span class="arithmatex">\(10000\)</span>.</p>
<p>The above uses <span class="arithmatex">\(n = 4\)</span> as an example, and it can be generalized to binary numbers of any number of bits.</p>
<!-- Source file information -->