Why console.log(0.1 + 0.2) != 0.3 #shorts #spancoders #viral
10/25/2025
Have you ever seen console.log(0.1 + 0.2) return 0.30000000000000004 instead of 0.3 in JavaScript? 🤔 This isn’t a bug — it’s how floating point arithmetic works in computers! 💻 In this short, we’ll explain why JavaScript (and most languages) can’t store decimals like 0.1 and 0.2 perfectly, and how binary floating-point math causes this weird result. 👉 Watch till the end to learn how to fix it using methods like toFixed() and Number.EPSILON. #JavaScript #CodingFacts #JSFloatError #DevShorts #ProgrammingExplained #SpanCoders #TechSimplified javascript javascript tutorial javascript floating point javascript 0.1 + 0.2 0.1 + 0.2 != 0.3 why 0.1 + 0.2 not equal 0.3 floating point error javascript precision issue javascript math error javascript explanation coding facts developer facts javascript tips web development programming explained learn javascript span coders tech shorts coding shorts js bug explained number precision javascript ieee 754 floating point math bug javascript javascript basics javascript interview question