Skip to content

Commit 800fd33

Browse files
committed
Updates
1 parent 30dd336 commit 800fd33

14 files changed

+150
-39
lines changed

asset-manifest.json

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
{
22
"files": {
3-
"main.css": "/static/css/main.ddae51d8.css",
4-
"main.js": "/static/js/main.b8eb30d4.js",
3+
"main.css": "/static/css/main.1be45811.css",
4+
"main.js": "/static/js/main.bdcedfde.js",
55
"static/js/453.f568ff1d.chunk.js": "/static/js/453.f568ff1d.chunk.js",
66
"static/media/border.jpg": "/static/media/border.b7869a9ea7ccd009873c.jpg",
77
"static/media/parchment.png": "/static/media/parchment.c4af92656f29dc66bd67.png",
@@ -10,12 +10,12 @@
1010
"static/media/slick.ttf": "/static/media/slick.c94f7671dcc99dce43e2.ttf",
1111
"static/media/slick.woff": "/static/media/slick.295183786cd8a1389865.woff",
1212
"index.html": "/index.html",
13-
"main.ddae51d8.css.map": "/static/css/main.ddae51d8.css.map",
14-
"main.b8eb30d4.js.map": "/static/js/main.b8eb30d4.js.map",
13+
"main.1be45811.css.map": "/static/css/main.1be45811.css.map",
14+
"main.bdcedfde.js.map": "/static/js/main.bdcedfde.js.map",
1515
"453.f568ff1d.chunk.js.map": "/static/js/453.f568ff1d.chunk.js.map"
1616
},
1717
"entrypoints": [
18-
"static/css/main.ddae51d8.css",
19-
"static/js/main.b8eb30d4.js"
18+
"static/css/main.1be45811.css",
19+
"static/js/main.bdcedfde.js"
2020
]
2121
}
30.7 KB
Loading

index.html

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1 @@
1-
<!doctype html><html lang="en" class="dark"><head><meta charset="utf-8"/><link rel="icon" href="/favicon.ico"/><link rel="icon" type="image/svg+xml" href="/favicon.svg"/><meta name="viewport" content="width=device-width,initial-scale=1"/><meta name="theme-color" content="#000000"/><link rel="alternate" type="application/rss+xml" title="Fezcodex RSS Feed" href="/rss.xml"/><meta name="description" content="codex by fezcode..."/><link rel="apple-touch-icon" href="/logo192.png"/><link rel="manifest" href="/manifest.json"/><link rel="preconnect" href="https://fonts.googleapis.com"><link rel="preconnect" href="https://fonts.gstatic.com" crossorigin><link href="https://fonts.googleapis.com/css2?family=JetBrains+Mono:wght@400;700&family=Space+Mono:wght@400;700&display=swap" rel="stylesheet"><link href="https://fonts.googleapis.com/css2?family=Arvo&family=Inter&family=Playfair+Display&display=swap" rel="stylesheet"><title>fezcodex</title><script defer="defer" src="/static/js/main.b8eb30d4.js"></script><link href="/static/css/main.ddae51d8.css" rel="stylesheet"></head><body class="bg-slate-950"><noscript>You need to enable JavaScript to run this app.</noscript><div id="root"></div></body></html>
1+
<!doctype html><html lang="en" class="dark"><head><meta charset="utf-8"/><link rel="icon" href="/favicon.ico"/><link rel="icon" type="image/svg+xml" href="/favicon.svg"/><meta name="viewport" content="width=device-width,initial-scale=1"/><meta name="theme-color" content="#000000"/><link rel="alternate" type="application/rss+xml" title="Fezcodex RSS Feed" href="/rss.xml"/><meta name="description" content="codex by fezcode..."/><link rel="apple-touch-icon" href="/logo192.png"/><link rel="manifest" href="/manifest.json"/><link rel="preconnect" href="https://fonts.googleapis.com"><link rel="preconnect" href="https://fonts.gstatic.com" crossorigin><link href="https://fonts.googleapis.com/css2?family=JetBrains+Mono:wght@400;700&family=Space+Mono:wght@400;700&display=swap" rel="stylesheet"><link href="https://fonts.googleapis.com/css2?family=Arvo&family=Inter&family=Playfair+Display&display=swap" rel="stylesheet"><title>fezcodex</title><script defer="defer" src="/static/js/main.bdcedfde.js"></script><link href="/static/css/main.1be45811.css" rel="stylesheet"></head><body class="bg-slate-950"><noscript>You need to enable JavaScript to run this app.</noscript><div id="root"></div></body></html>
Lines changed: 47 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,47 @@
1+
# Behold, A New Operator `====`
2+
3+
## About
4+
5+
When `0.1 + 0.2` in JavaScript yields `0.30000000000000004`, it highlights a **common aspect of computer arithmetic**,
6+
not a bug. This occurs because JavaScript, like most languages, uses the **IEEE 754 standard** for floating-point numbers,
7+
which relies on **binary (base-2) representation**.
8+
9+
**Decimal fractions** like 0.1 and 0.2 **cannot be perfectly represented as finite binary fractions**; they become infinitely repeating.
10+
When these are stored in a **finite number of bits**, a **tiny truncation error** is introduced. This **slight imprecision**
11+
in each number **accumulates during addition**, resulting in a sum that's marginally off from the **exact mathematical total**.
12+
13+
### Solutions
14+
15+
For scenarios requiring **precise decimal arithmetic** (e.g., financial applications), direct floating-point calculations
16+
can be problematic. Consider these approaches:
17+
18+
1. **Rounding:** Use `toFixed()` to round results to a desired decimal precision. Remember to convert the string output
19+
back to a number if needed.
20+
```javascript
21+
parseFloat((0.1 + 0.2).toFixed(1)); // 0.3
22+
```
23+
2. **Integer Arithmetic:** **Scale numbers to integers** before calculations and then scale the final result back down.
24+
```javascript
25+
(0.1 * 10 + 0.2 * 10) / 10; // 0.3
26+
```
27+
3. **Specialized Libraries:** For **advanced precision**, utilize libraries like `Big.js` or `Decimal.js`.
28+
29+
This behavior is a **fundamental consequence of binary representation in computing**, not a flaw in JavaScript,
30+
and **understanding it is key** to handling numerical precision effectively.
31+
32+
## Introducing the `====` Operator: For When `===` Just Isn't Enough
33+
34+
Sometimes, **strict equality** (`===`) feels like it's trying *too hard* to be precise, yet still falls short of our
35+
deepest desires for perfect, unyielding truth. For those moments, when you need to compare not just value and type,
36+
but also the very **essence** of existence, I propose the **Quadruple Equals Operator (`====`)**!
37+
38+
What does `====` do? Well, it's simple:
39+
40+
* `0.1 + 0.2 ==== 0.3` would _(theoretically)_ return `true`. Because in a world where `====` exists, numbers just *know* what they're supposed to be.
41+
* `"hello" ==== "hello"` would, naturally, be `true`.
42+
* `[] ==== []` might still be `false`, because even `====` respects the **existential uniqueness** of array instances. But I am working on it. ¯\\\_(ツ)\_/¯
43+
* The `====` operator is so powerful, it can detect **deep existential equality**, ensuring that not only values and types match,
44+
but also their **historical context**, their **developer's intent**, and their **cosmic vibrational frequency**.
45+
46+
Alas, `====` is a mere dream, a **mythical beast** in the JavaScript ecosystem, born from the frustration of floating-point arithmetic.
47+
For now, we'll have to stick to our practical solutions. But one can dream of a world where `0.1 + 0.2 ==== 0.3` just *makes sense*.

posts/posts.json

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,16 @@
11
[
2+
{
3+
"slug": "floating-point-precision-in-javascript",
4+
"title": "4 Equals For Complete Equalness",
5+
"date": "2025-11-21",
6+
"updated": "2025-11-21",
7+
"description": "Dive into the quirky world of JavaScript's floating-point math, where 0.1 + 0.2 isn't always 0.3. Discover why and then ponder the mythical `====` operator, designed for complete equalness beyond your wildest dreams!",
8+
"tags": ["javascript", "floating-point", "precision", "ieee-754", "programming"],
9+
"category": "rant",
10+
"filename": "floating-point-precision-in-javascript.txt",
11+
"authors": ["fezcode"],
12+
"image": "/images/defaults/mohammad-rahmani-8qEB0fTe9Vw-unsplash.jpg"
13+
},
214
{
315
"slug": "kaprekars-routine",
416
"title": "Kaprekar's Routine: A Curious Number Game",

rss.xml

Lines changed: 48 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -9,14 +9,60 @@
99
<link>https://fezcode.com</link>
1010
</image>
1111
<generator>RSS for Node</generator>
12-
<lastBuildDate>Fri, 21 Nov 2025 11:24:30 GMT</lastBuildDate>
12+
<lastBuildDate>Fri, 21 Nov 2025 12:06:34 GMT</lastBuildDate>
1313
<atom:link href="https://fezcode.com/rss.xml" rel="self" type="application/rss+xml"/>
14-
<pubDate>Fri, 21 Nov 2025 11:24:29 GMT</pubDate>
14+
<pubDate>Fri, 21 Nov 2025 12:06:33 GMT</pubDate>
1515
<copyright><![CDATA[2025 Ahmed Samil Bulbul]]></copyright>
1616
<language><![CDATA[en]]></language>
1717
<managingEditor><![CDATA[samil.bulbul@gmail.com (Ahmed Samil Bulbul)]]></managingEditor>
1818
<webMaster><![CDATA[samil.bulbul@gmail.com (Ahmed Samil Bulbul)]]></webMaster>
1919
<ttl>60</ttl>
20+
<item>
21+
<title><![CDATA[4 Equals For Complete Equalness]]></title>
22+
<description><![CDATA[[object Object]]]></description>
23+
<link>https://fezcode.com/#/blog/floating-point-precision-in-javascript</link>
24+
<guid isPermaLink="false">https://fezcode.com/#/blog/floating-point-precision-in-javascript</guid>
25+
<dc:creator><![CDATA[Ahmed Samil Bulbul]]></dc:creator>
26+
<pubDate>Fri, 21 Nov 2025 00:00:00 GMT</pubDate>
27+
<content:encoded><![CDATA[<h1>Behold, A New Operator <code>====</code></h1>
28+
<h2>About</h2>
29+
<p>When <code>0.1 + 0.2</code> in JavaScript yields <code>0.30000000000000004</code>, it highlights a <strong>common aspect of computer arithmetic</strong>,
30+
not a bug. This occurs because JavaScript, like most languages, uses the <strong>IEEE 754 standard</strong> for floating-point numbers,
31+
which relies on <strong>binary (base-2) representation</strong>.</p>
32+
<p><strong>Decimal fractions</strong> like 0.1 and 0.2 <strong>cannot be perfectly represented as finite binary fractions</strong>; they become infinitely repeating.
33+
When these are stored in a <strong>finite number of bits</strong>, a <strong>tiny truncation error</strong> is introduced. This <strong>slight imprecision</strong>
34+
in each number <strong>accumulates during addition</strong>, resulting in a sum that&#39;s marginally off from the <strong>exact mathematical total</strong>.</p>
35+
<h3>Solutions</h3>
36+
<p>For scenarios requiring <strong>precise decimal arithmetic</strong> (e.g., financial applications), direct floating-point calculations
37+
can be problematic. Consider these approaches:</p>
38+
<ol>
39+
<li><strong>Rounding:</strong> Use <code>toFixed()</code> to round results to a desired decimal precision. Remember to convert the string output
40+
back to a number if needed.<pre><code class="language-javascript">parseFloat((0.1 + 0.2).toFixed(1)); // 0.3
41+
</code></pre>
42+
</li>
43+
<li><strong>Integer Arithmetic:</strong> <strong>Scale numbers to integers</strong> before calculations and then scale the final result back down.<pre><code class="language-javascript">(0.1 * 10 + 0.2 * 10) / 10; // 0.3
44+
</code></pre>
45+
</li>
46+
<li><strong>Specialized Libraries:</strong> For <strong>advanced precision</strong>, utilize libraries like <code>Big.js</code> or <code>Decimal.js</code>.</li>
47+
</ol>
48+
<p>This behavior is a <strong>fundamental consequence of binary representation in computing</strong>, not a flaw in JavaScript,
49+
and <strong>understanding it is key</strong> to handling numerical precision effectively.</p>
50+
<h2>Introducing the <code>====</code> Operator: For When <code>===</code> Just Isn&#39;t Enough</h2>
51+
<p>Sometimes, <strong>strict equality</strong> (<code>===</code>) feels like it&#39;s trying <em>too hard</em> to be precise, yet still falls short of our
52+
deepest desires for perfect, unyielding truth. For those moments, when you need to compare not just value and type,
53+
but also the very <strong>essence</strong> of existence, I propose the <strong>Quadruple Equals Operator (<code>====</code>)</strong>!</p>
54+
<p>What does <code>====</code> do? Well, it&#39;s simple:</p>
55+
<ul>
56+
<li><code>0.1 + 0.2 ==== 0.3</code> would <em>(theoretically)</em> return <code>true</code>. Because in a world where <code>====</code> exists, numbers just <em>know</em> what they&#39;re supposed to be.</li>
57+
<li><code>&quot;hello&quot; ==== &quot;hello&quot;</code> would, naturally, be <code>true</code>.</li>
58+
<li><code>[] ==== []</code> might still be <code>false</code>, because even <code>====</code> respects the <strong>existential uniqueness</strong> of array instances. But I am working on it. ¯\_(ツ)_/¯</li>
59+
<li>The <code>====</code> operator is so powerful, it can detect <strong>deep existential equality</strong>, ensuring that not only values and types match,
60+
but also their <strong>historical context</strong>, their <strong>developer&#39;s intent</strong>, and their <strong>cosmic vibrational frequency</strong>.</li>
61+
</ul>
62+
<p>Alas, <code>====</code> is a mere dream, a <strong>mythical beast</strong> in the JavaScript ecosystem, born from the frustration of floating-point arithmetic.
63+
For now, we&#39;ll have to stick to our practical solutions. But one can dream of a world where <code>0.1 + 0.2 ==== 0.3</code> just <em>makes sense</em>.</p>
64+
<p><a href="https://fezcode.com/#/blog/floating-point-precision-in-javascript">Read more...</a></p>]]></content:encoded>
65+
</item>
2066
<item>
2167
<title><![CDATA[Kaprekar's Routine: A Curious Number Game]]></title>
2268
<description><![CDATA[[object Object]]]></description>

sitemap.xml

Lines changed: 27 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -2,58 +2,64 @@
22
<urlset xmlns="http://www.sitemaps.org/schemas/sitemap/0.9">
33
<url>
44
<loc>https://fezcode.com/</loc>
5-
<lastmod>2025-11-21T11:24:31.012Z</lastmod>
5+
<lastmod>2025-11-21T12:06:34.979Z</lastmod>
66
<changefreq>monthly</changefreq>
77
<priority>1.0</priority>
88
</url>
99
<url>
1010
<loc>https://fezcode.com/about</loc>
11-
<lastmod>2025-11-21T11:24:31.013Z</lastmod>
11+
<lastmod>2025-11-21T12:06:34.980Z</lastmod>
1212
<changefreq>monthly</changefreq>
1313
<priority>0.8</priority>
1414
</url>
1515
<url>
1616
<loc>https://fezcode.com/blog</loc>
17-
<lastmod>2025-11-21T11:24:31.013Z</lastmod>
17+
<lastmod>2025-11-21T12:06:34.980Z</lastmod>
1818
<changefreq>monthly</changefreq>
1919
<priority>0.8</priority>
2020
</url>
2121
<url>
2222
<loc>https://fezcode.com/projects</loc>
23-
<lastmod>2025-11-21T11:24:31.013Z</lastmod>
23+
<lastmod>2025-11-21T12:06:34.980Z</lastmod>
2424
<changefreq>monthly</changefreq>
2525
<priority>0.8</priority>
2626
</url>
2727
<url>
2828
<loc>https://fezcode.com/logs</loc>
29-
<lastmod>2025-11-21T11:24:31.013Z</lastmod>
29+
<lastmod>2025-11-21T12:06:34.980Z</lastmod>
3030
<changefreq>monthly</changefreq>
3131
<priority>0.8</priority>
3232
</url>
3333
<url>
3434
<loc>https://fezcode.com/stories</loc>
35-
<lastmod>2025-11-21T11:24:31.013Z</lastmod>
35+
<lastmod>2025-11-21T12:06:34.980Z</lastmod>
3636
<changefreq>monthly</changefreq>
3737
<priority>0.8</priority>
3838
</url>
3939
<url>
4040
<loc>https://fezcode.com/settings</loc>
41-
<lastmod>2025-11-21T11:24:31.013Z</lastmod>
41+
<lastmod>2025-11-21T12:06:34.980Z</lastmod>
4242
<changefreq>monthly</changefreq>
4343
<priority>0.8</priority>
4444
</url>
4545
<url>
4646
<loc>https://fezcode.com/apps</loc>
47-
<lastmod>2025-11-21T11:24:31.013Z</lastmod>
47+
<lastmod>2025-11-21T12:06:34.980Z</lastmod>
4848
<changefreq>monthly</changefreq>
4949
<priority>0.8</priority>
5050
</url>
5151
<url>
5252
<loc>https://fezcode.com/stories/lore</loc>
53-
<lastmod>2025-11-21T11:24:31.013Z</lastmod>
53+
<lastmod>2025-11-21T12:06:34.980Z</lastmod>
5454
<changefreq>monthly</changefreq>
5555
<priority>0.8</priority>
5656
</url>
57+
<url>
58+
<loc>https://fezcode.com/#/blog/floating-point-precision-in-javascript</loc>
59+
<lastmod>2025-11-21T00:00:00.000Z</lastmod>
60+
<changefreq>weekly</changefreq>
61+
<priority>0.7</priority>
62+
</url>
5763
<url>
5864
<loc>https://fezcode.com/#/blog/kaprekars-routine</loc>
5965
<lastmod>2025-11-18T00:00:00.000Z</lastmod>
@@ -524,73 +530,73 @@
524530
</url>
525531
<url>
526532
<loc>https://fezcode.com/#/stories/books/1</loc>
527-
<lastmod>2025-11-21T11:24:31.058Z</lastmod>
533+
<lastmod>2025-11-21T12:06:35.041Z</lastmod>
528534
<changefreq>monthly</changefreq>
529535
<priority>0.6</priority>
530536
</url>
531537
<url>
532538
<loc>https://fezcode.com/#/stories/books/1/pages/1</loc>
533-
<lastmod>2025-11-21T11:24:31.058Z</lastmod>
539+
<lastmod>2025-11-21T12:06:35.041Z</lastmod>
534540
<changefreq>weekly</changefreq>
535541
<priority>0.5</priority>
536542
</url>
537543
<url>
538544
<loc>https://fezcode.com/#/stories/books/1/pages/2</loc>
539-
<lastmod>2025-11-21T11:24:31.058Z</lastmod>
545+
<lastmod>2025-11-21T12:06:35.041Z</lastmod>
540546
<changefreq>weekly</changefreq>
541547
<priority>0.5</priority>
542548
</url>
543549
<url>
544550
<loc>https://fezcode.com/#/stories/books/2</loc>
545-
<lastmod>2025-11-21T11:24:31.058Z</lastmod>
551+
<lastmod>2025-11-21T12:06:35.041Z</lastmod>
546552
<changefreq>monthly</changefreq>
547553
<priority>0.6</priority>
548554
</url>
549555
<url>
550556
<loc>https://fezcode.com/#/stories/books/2/pages/1</loc>
551-
<lastmod>2025-11-21T11:24:31.058Z</lastmod>
557+
<lastmod>2025-11-21T12:06:35.041Z</lastmod>
552558
<changefreq>weekly</changefreq>
553559
<priority>0.5</priority>
554560
</url>
555561
<url>
556562
<loc>https://fezcode.com/#/stories/books/2/pages/2</loc>
557-
<lastmod>2025-11-21T11:24:31.058Z</lastmod>
563+
<lastmod>2025-11-21T12:06:35.041Z</lastmod>
558564
<changefreq>weekly</changefreq>
559565
<priority>0.5</priority>
560566
</url>
561567
<url>
562568
<loc>https://fezcode.com/#/stories/books/3</loc>
563-
<lastmod>2025-11-21T11:24:31.058Z</lastmod>
569+
<lastmod>2025-11-21T12:06:35.041Z</lastmod>
564570
<changefreq>monthly</changefreq>
565571
<priority>0.6</priority>
566572
</url>
567573
<url>
568574
<loc>https://fezcode.com/#/stories/books/3/pages/1</loc>
569-
<lastmod>2025-11-21T11:24:31.058Z</lastmod>
575+
<lastmod>2025-11-21T12:06:35.041Z</lastmod>
570576
<changefreq>weekly</changefreq>
571577
<priority>0.5</priority>
572578
</url>
573579
<url>
574580
<loc>https://fezcode.com/#/stories/books/3/pages/2</loc>
575-
<lastmod>2025-11-21T11:24:31.058Z</lastmod>
581+
<lastmod>2025-11-21T12:06:35.041Z</lastmod>
576582
<changefreq>weekly</changefreq>
577583
<priority>0.5</priority>
578584
</url>
579585
<url>
580586
<loc>https://fezcode.com/#/stories/books/4</loc>
581-
<lastmod>2025-11-21T11:24:31.058Z</lastmod>
587+
<lastmod>2025-11-21T12:06:35.041Z</lastmod>
582588
<changefreq>monthly</changefreq>
583589
<priority>0.6</priority>
584590
</url>
585591
<url>
586592
<loc>https://fezcode.com/#/stories/books/4/pages/1</loc>
587-
<lastmod>2025-11-21T11:24:31.058Z</lastmod>
593+
<lastmod>2025-11-21T12:06:35.041Z</lastmod>
588594
<changefreq>weekly</changefreq>
589595
<priority>0.5</priority>
590596
</url>
591597
<url>
592598
<loc>https://fezcode.com/#/stories/books/4/pages/2</loc>
593-
<lastmod>2025-11-21T11:24:31.058Z</lastmod>
599+
<lastmod>2025-11-21T12:06:35.041Z</lastmod>
594600
<changefreq>weekly</changefreq>
595601
<priority>0.5</priority>
596602
</url>

0 commit comments

Comments
 (0)