@legitalgorithmswithpeter: 🤯 Your computer can’t calculate 0.1 + 0.2 correctly. And a similar rounding error once contributed to the deaths of 28 soldiers. Here’s why. 💻 Computers store numbers in binary, not decimal. Just like 1/3 becomes 0.3333… forever, numbers like 0.1 have repeating binary representations. IEEE 754 floating-point numbers have limited precision, so the computer stores the closest representable value instead. That’s why in languages like Python and JavaScript: 0.1 + 0.2 !== 0.3 😳 Usually harmless. But tiny errors can become dangerous when they accumulate over time. 🚨 In 1991, a Patriot missile system in Saudi Arabia suffered a timing error after running for around 100 hours. The accumulated drift contributed to its failure to track an incoming Scud missile. The missile struck a barracks, killing 28 soldiers. 🔥 How developers avoid these problems: ✅ Use integers for money, such as cents. ✅ Use exact decimal types when appropriate, like Java’s BigDecimal or Python’s Decimal. ✅ Compare floating-point numbers using a tolerance instead of exact equality. One tiny rounding error can teach a massive lesson about software engineering. 💬 Want to learn how banks handle precision in financial systems? Comment below! #Programming #FloatingPoint #SoftwareEngineering #ComputerScience #Coding
algorithmswithpeter
Region: US
Tuesday 20 October 2026 14:46:00 GMT
Music
Download
Comments
Epi_Tu :
How do banks avoid this
2026-10-20 21:10:22
129
dexomh2 :
this is why 0.33... + 0.33... + 0.33.. is 1 by convention, it's error correction, but often confused by arm chair mathematicians as a proof that numbers that are infinitely close are identical.
2026-10-21 09:10:17
0
Aaron Cowie :
in c# using decimal it works fine
2026-10-20 20:12:57
13
️ :
this same little quirk did what now
2026-10-21 11:03:51
0
jeffry.st.brnrd :
When doing taxes, simply ignore the cents. $1255.77? $1255. Truncate, never round.
2026-10-21 10:56:48
0
Deastrom :
lesson. don't make decisions based on fractions.
2026-10-20 20:08:09
6
tree :
yeah need to know how banks avoid this
2026-10-20 15:26:01
98
Casper :
Thanks Petah Guy
2026-10-21 06:06:19
0
שי🔱טל 💪 :
That’s the reason why developers avoid decimals unless they have to
2026-10-20 18:35:32
551
Terry :
Use integers.
2026-10-21 09:06:49
0
Dibu Elniv :
you can used fixed point arithmetic of any precision of your choosing, and for timing, typically integer math is used, where one bit has a defined duration e.g. 1 microsecond, you dont use floating point for time related math
2026-10-20 17:05:05
31
f4nt45y_ :
0.999 is equal to 1.
2026-10-21 06:19:21
0
Fernando M :
all we have to do is use remainders
2026-10-21 05:41:31
0
skitty :
bro type bc into the terminal
2026-10-21 06:39:46
0
Rotacioskapa :
c# has decimal data type for that brother
2026-10-21 08:42:16
0
Austin Bachurski :
64 bitis.
2026-10-20 18:41:13
35
MURCS :
INSTANT DOWNLOAD!
If this doesnt go viral, we are doomed.
2026-10-21 00:57:03
0
JJ :
Thanks for teaching me Peter
2026-10-20 23:16:31
25
Mawethu (The Marathon Savant) :
that was a bit off 😅
2026-10-20 17:13:05
7
gromit424 :
Just don't use floating point.
2026-10-20 21:10:52
1
NM :
That actually sounds exactly as a bug and programming issue of the languages
2026-10-20 18:33:05
2
xafer :
so turn it off and on again every hour? got it.
2026-10-20 18:58:35
3
Євгеній Мураєв🇮🇷💪 :
I know an multinational Enterprise who add floats in javascript in 2024🤦🏻♂️🤦🏻♂️🤦🏻♂️
2026-10-20 20:55:55
1
SkizMonkey :
I heard that banks use binary coded decimal arithmetic.
2026-10-21 05:37:24
1
🇬🇧baz_uk🏴 :
feels weird getting schooled by Peter griffin
2026-10-21 00:06:49
2
To see more videos from user @legitalgorithmswithpeter, please go to the Tikwm
homepage.