<?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="https://terryliu.dev/feed.xml" rel="self" type="application/atom+xml" /><link href="https://terryliu.dev/" rel="alternate" type="text/html" /><updated>2026-08-03T10:50:36-07:00</updated><id>https://terryliu.dev/feed.xml</id><title type="html">terryLiu.dev</title><subtitle>Musings on 1s and 0s</subtitle><author><name>Terry Liu</name></author><entry><title type="html">Floating Point Arithmetic</title><link href="https://terryliu.dev/2024/07/01/floating-point-arithmetic.html" rel="alternate" type="text/html" title="Floating Point Arithmetic" /><published>2024-07-01T01:11:00-07:00</published><updated>2024-07-01T01:11:00-07:00</updated><id>https://terryliu.dev/2024/07/01/floating-point-arithmetic</id><content type="html" xml:base="https://terryliu.dev/2024/07/01/floating-point-arithmetic.html"><![CDATA[<p>I’ve come across this numerous times in my career thus far and have the lesson ingrained in me, but
I wanted to write something really quick to cover the perils of floating point arithmetic.</p>

<p>For the uninitiated, the problem of doing floating point arithmetic can be summarized by trying this
in Python (or almost any other language for that matter):</p>
<div class="language-python highlighter-rouge"><div class="highlight"><pre class="highlight"><code><span class="o">&gt;&gt;&gt;</span> <span class="mf">1.3</span> <span class="o">+</span> <span class="mf">0.1</span>
<span class="mf">1.4000000000000001</span>
</code></pre></div></div>

<p>I know. Shocking, right?! There are many resources that go into great detail about why this happens,
so I won’t do it here. Suffice it to say that the “floating point” type is imprecise due to the
nature of how the number is stored in computing.</p>

<p>When doing any precise math (e.g. financial applications), you should be using a proper “Decimal”
type to address this, and every respectable language should have one, either natively or as a
package.</p>

<p>Note that for Python, the input to <code class="language-plaintext highlighter-rouge">Decimal()</code> should be a <strong>string</strong>, which is its own gotcha
🤦🏻‍♂️:</p>
<div class="language-python highlighter-rouge"><div class="highlight"><pre class="highlight"><code><span class="o">&gt;&gt;&gt;</span> <span class="kn">from</span> <span class="nn">decimal</span> <span class="kn">import</span> <span class="n">Decimal</span>
<span class="o">&gt;&gt;&gt;</span> <span class="n">Decimal</span><span class="p">(</span><span class="s">'1.3'</span><span class="p">)</span> <span class="o">+</span> <span class="n">Decimal</span><span class="p">(</span><span class="s">'0.1'</span><span class="p">)</span>
<span class="n">Decimal</span><span class="p">(</span><span class="s">'1.4'</span><span class="p">)</span>
</code></pre></div></div>

<p>Until next time, happy hacking!</p>]]></content><author><name>Terry Liu</name></author><summary type="html"><![CDATA[I’ve come across this numerous times in my career thus far and have the lesson ingrained in me, but I wanted to write something really quick to cover the perils of floating point arithmetic.]]></summary></entry><entry><title type="html">New blog, who dis?</title><link href="https://terryliu.dev/2024/06/23/new-blog-who-dis.html" rel="alternate" type="text/html" title="New blog, who dis?" /><published>2024-06-23T09:30:00-07:00</published><updated>2024-06-23T09:30:00-07:00</updated><id>https://terryliu.dev/2024/06/23/new-blog-who-dis</id><content type="html" xml:base="https://terryliu.dev/2024/06/23/new-blog-who-dis.html"><![CDATA[<p>I technically started this blog many years ago but never made the time to post meaningful content.
Now that AI is here to help and I have far more experience under my belt, it feels like a great time
to have a place to journal my thoughts on tech and perhaps share some of my past work in more detail
than can fit on a résumé.</p>

<p>It feels appropriate to dedicate this first post to the key technologies enabling its existence:</p>
<ul>
  <li><a href="https://pages.github.com/">GitHub Pages</a></li>
  <li><a href="https://jekyllrb.com/">Jekyll</a></li>
  <li><a href="https://mmistakes.github.io/minimal-mistakes/">“Minimal Mistakes” theme</a></li>
  <li><a href="https://www.markdownguide.org/">Markdown</a></li>
  <li><a href="https://sass-lang.com/">Sass</a></li>
  <li>HTML, CSS, JS (of course!)</li>
  <li>Your favorite domain registrar (optional)</li>
</ul>

<p>It’s worth noting that this setup is not exactly user-friendly, especially for anyone new to tech,
but it can also be hosted for free (minus the cost of custom domain) if you’re okay with having its
contents be publicly accessible on GitHub. You can also pay a GitHub subscription to enable
privatizing the contents.</p>

<p>If you’re strictly looking to blog with a low-maintenance, well-supported, feature-full editor, I
can’t really recommend this route given the number of other great specialized services for that
purpose.</p>

<p>However, if you’re curious about tech at all and just want to have your own (static)
website for whatever reason, it’s never too late to learn!</p>

<p>Until next time, happy hacking!</p>]]></content><author><name>Terry Liu</name></author><summary type="html"><![CDATA[I technically started this blog many years ago but never made the time to post meaningful content. Now that AI is here to help and I have far more experience under my belt, it feels like a great time to have a place to journal my thoughts on tech and perhaps share some of my past work in more detail than can fit on a résumé.]]></summary></entry></feed>