JavaScript's Unique Approach to Basic Arithmetic
Description
This meme uses the 'Woman Showing Paper to a Cat' format. The top part of the image contains a text exchange: 'Teacher: How much is 1.1 * 3 ?', 'He: 3.3', 'Teacher: Then why did you write 3.3000000000000003 ?'. The bottom panel shows a woman looking at a paper with a small grey cat, and a zoomed-in image of the cat looking stressed and guilty. The cat is labeled 'JavaScript developer'. The humor stems from a well-known quirk in JavaScript (and other languages using IEEE 754 floating-point arithmetic) where simple decimal calculations result in precision errors. The expression `1.1 * 3` evaluates to the long decimal because of how these numbers are represented in binary. The meme personifies this language flaw as a developer being caught making a fundamental math error, perfectly capturing the frustrating and often comical nature of floating-point inaccuracies
Comments
28Comment deleted
This is why we have a `===` operator. One equals is for the value, one is for the type, and the third is to check if the floating-point representation is having an existential crisis
PM: “Can we stop showing 3.3000000000000003 on the invoice?” Me: “Sure - just budget a sprint to replace IEEE-754, every browser VM, and probably a few laws of physics.”
After 20 years in the industry, you learn that the real skill isn't avoiding floating-point errors - it's explaining to the finance team why their quarterly reports are off by 0.0000000000000003 cents and convincing them it's actually the computer being mathematically correct
Every JavaScript developer has had that moment explaining to a stakeholder why their financial calculations are off by 0.0000000000000003. 'It's not a bug, it's IEEE 754!' we cry, while frantically googling decimal.js libraries and wondering why we didn't just use integers and store everything in cents like the backend team suggested three sprints ago
I didn’t fail math - I passed IEEE‑754: 3.3 is a UI concern; 3.300000000000003 is the backend truth
In JavaScript, 1.1*3 equals an IEEE‑754 footnote, a decimal library, and an awkward finance call
Because JS multiplies like microservices: distributed accuracy with consistency eventually
why exclusively js? Comment deleted
Yes Comment deleted
https://0.30000000000000004.com/ Comment deleted
brilliant Comment deleted
When you hate JS for 0.1+0.2 != 0.3 you should in the same way hate Rust, C++, python, Haskell, your CPU and at last William Kahan) Comment deleted
+1. Comment deleted
Floating point errors are really something Comment deleted
is there a language where 1.1*3 is actually 3.3? Comment deleted
haskell and lisp Comment deleted
they use fractions and floats Comment deleted
and how are there 1.1*3=3.3? Comment deleted
common lisp (sbcl) * (* 1.1 3) 3.3000002 haskell Prelude> 1.1 * 3 3.3000000000000003 Comment deleted
if you do the 11 % 10 Comment deleted
? Comment deleted
represent 1.1 as rational Comment deleted
* (float (* (rationalize 1.1) 3)) 3.3 Comment deleted
ye like this it's gonna produce trash Comment deleted
Sbcl: (/ 3 10) 3/10 Comment deleted
Even IRL 1.1*3 can be 3.2999(9) Comment deleted
python kek Comment deleted
fukkk whyyy Comment deleted