Why 0.1 + 0.2 = 0.30000000000000004 in JavaScript? | Floating Point Precision Explained

Опубликовано: 22 Сентябрь 2026
на канале: Prashant Kumar
13
1

🤯 Why does this happen? Where does that extra 04 come from?


In this video, I explain JavaScript floating-point precision in simple terms and show what happens when decimal numbers are represented internally using binary floating-point numbers.
In this video:


Why 0.1 + 0.2 doesn't give exactly 0.3

How computers represent numbers in binary

Why 0.1 and 0.2 cannot be represented exactly

Where the extra digits come from

What floating-point precision actually means

How toFixed() can help with simple decimal formatting #coding #developer #programming #javascript #nodejs #webdevelopment

Why financial calculations need more careful handling



Important: toFixed() is not a universal solution for financial calculations; production financial systems should use appropriate decimal/integer-based techniques.




JavaScript, JavaScript floating point precision, 0.1 + 0.2 JavaScript, 0.30000000000000004, floating point precision explained, JavaScript explained, JavaScript tutorial, JavaScript bugs, JavaScript interview questions, programming, coding, web development, frontend development, JavaScript tips, developer tips, binary numbers, IEEE 754