Skip to content

Commit 799a2b2

Browse files
committed
whoops forgot to add giscus comments to 2's complement post
1 parent d0581f0 commit 799a2b2

File tree

2 files changed

+22
-2
lines changed

2 files changed

+22
-2
lines changed

_posts/2025-12-08-2s-complement.md

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -39,3 +39,20 @@ When we flip the bits of `x`, this new bit we added will also get flipped along
3939
Putting all the pieces together, we get that for a number `x` represented by `n` bits (with an extra bit having a place value of `-2^n`) where `x = (2^n - 1) - ~x`, you would need to flip its bits and add one to get `-2^n + ~x + 1 = -x`.
4040

4141
Hopefully after reading this, you will have gained a better understanding of using 2's complement for converting binary numbers to negative.
42+
43+
<script src="https://giscus.app/client.js"
44+
data-repo="de-soot/de-soot.github.io"
45+
data-repo-id="R_kgDOK6_5tA"
46+
data-category="Announcements"
47+
data-category-id="DIC_kwDOK6_5tM4CflCT"
48+
data-mapping="title"
49+
data-strict="0"
50+
data-reactions-enabled="1"
51+
data-emit-metadata="0"
52+
data-input-position="top"
53+
data-theme="preferred_color_scheme"
54+
data-lang="en"
55+
data-loading="lazy"
56+
crossorigin="anonymous"
57+
async>
58+
</script>

_site/feed.xml

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
<?xml version="1.0" encoding="utf-8"?><feed xmlns="http://www.w3.org/2005/Atom" ><generator uri="https://jekyllrb.com/" version="3.10.0">Jekyll</generator><link href="http://localhost:4000/feed.xml" rel="self" type="application/atom+xml" /><link href="http://localhost:4000/" rel="alternate" type="text/html" /><updated>2025-12-09T21:52:30+08:00</updated><id>http://localhost:4000/feed.xml</id><title type="html">de_soot</title><subtitle>Technical blog</subtitle><entry><title type="html">2’s Complement Derivation</title><link href="http://localhost:4000/2s-complement" rel="alternate" type="text/html" title="2’s Complement Derivation" /><published>2025-12-08T00:00:00+08:00</published><updated>2025-12-08T00:00:00+08:00</updated><id>http://localhost:4000/2s-complement</id><content type="html" xml:base="http://localhost:4000/2s-complement"><![CDATA[<p>If you have ever taken CS in high school or college, you have probably been taught about how to represent negative numbers in binary using 2’s complement.</p>
1+
<?xml version="1.0" encoding="utf-8"?><feed xmlns="http://www.w3.org/2005/Atom" ><generator uri="https://jekyllrb.com/" version="3.10.0">Jekyll</generator><link href="http://localhost:4000/feed.xml" rel="self" type="application/atom+xml" /><link href="http://localhost:4000/" rel="alternate" type="text/html" /><updated>2025-12-10T10:58:32+08:00</updated><id>http://localhost:4000/feed.xml</id><title type="html">de_soot</title><subtitle>Technical blog</subtitle><entry><title type="html">2’s Complement Derivation</title><link href="http://localhost:4000/2s-complement" rel="alternate" type="text/html" title="2’s Complement Derivation" /><published>2025-12-08T00:00:00+08:00</published><updated>2025-12-08T00:00:00+08:00</updated><id>http://localhost:4000/2s-complement</id><content type="html" xml:base="http://localhost:4000/2s-complement"><![CDATA[<p>If you have ever taken CS in high school or college, you have probably been taught about how to represent negative numbers in binary using 2’s complement.</p>
22
33
<p>But teachers generally just tell you to “flip the bits and add one” without really explaining why it works—similar to how high school teachers treat math formulas.</p>
44
@@ -30,7 +30,10 @@ When we flip the bits of <code class="language-plaintext highlighter-rouge">x</c
3030
3131
<p>Putting all the pieces together, we get that for a number <code class="language-plaintext highlighter-rouge">x</code> represented by <code class="language-plaintext highlighter-rouge">n</code> bits (with an extra bit having a place value of <code class="language-plaintext highlighter-rouge">-2^n</code>) where <code class="language-plaintext highlighter-rouge">x = (2^n - 1) - ~x</code>, you would need to flip its bits and add one to get <code class="language-plaintext highlighter-rouge">-2^n + ~x + 1 = -x</code>.</p>
3232
33-
<p>Hopefully after reading this, you will have gained a better understanding of using 2’s complement for converting binary numbers to negative.</p>]]></content><author><name></name></author><category term="cs," /><category term="binary," /><category term="bits," /><category term="negative" /><category term="numbers," /><category term="derivation," /><category term="proof," /><category term="math," /><category term="2&apos;s" /><category term="complement" /><summary type="html"><![CDATA[If you have ever taken CS in high school or college, you have probably been taught about how to represent negative numbers in binary using 2’s complement.]]></summary></entry><entry><title type="html">Guide to APA with groff ms and refer</title><link href="http://localhost:4000/groff-apa" rel="alternate" type="text/html" title="Guide to APA with groff ms and refer" /><published>2025-02-20T00:00:00+08:00</published><updated>2025-02-20T00:00:00+08:00</updated><id>http://localhost:4000/groff-apa</id><content type="html" xml:base="http://localhost:4000/groff-apa"><![CDATA[<p>This guide explains why and how I used groff with the ms and refer macros to write my college essay in Neovim.</p>
33+
<p>Hopefully after reading this, you will have gained a better understanding of using 2’s complement for converting binary numbers to negative.</p>
34+
35+
<script src="https://giscus.app/client.js" data-repo="de-soot/de-soot.github.io" data-repo-id="R_kgDOK6_5tA" data-category="Announcements" data-category-id="DIC_kwDOK6_5tM4CflCT" data-mapping="title" data-strict="0" data-reactions-enabled="1" data-emit-metadata="0" data-input-position="top" data-theme="preferred_color_scheme" data-lang="en" data-loading="lazy" crossorigin="anonymous" async="">
36+
</script>]]></content><author><name></name></author><category term="cs," /><category term="binary," /><category term="bits," /><category term="negative" /><category term="numbers," /><category term="derivation," /><category term="proof," /><category term="math," /><category term="2&apos;s" /><category term="complement" /><summary type="html"><![CDATA[If you have ever taken CS in high school or college, you have probably been taught about how to represent negative numbers in binary using 2’s complement.]]></summary></entry><entry><title type="html">Guide to APA with groff ms and refer</title><link href="http://localhost:4000/groff-apa" rel="alternate" type="text/html" title="Guide to APA with groff ms and refer" /><published>2025-02-20T00:00:00+08:00</published><updated>2025-02-20T00:00:00+08:00</updated><id>http://localhost:4000/groff-apa</id><content type="html" xml:base="http://localhost:4000/groff-apa"><![CDATA[<p>This guide explains why and how I used groff with the ms and refer macros to write my college essay in Neovim.</p>
3437
3538
<h1 id="1-table-of-contents-">1. Table of Contents <a name="tableofcontents"></a></h1>
3639

0 commit comments

Comments
 (0)