DEV Community

Geek Lady
Geek Lady

Posted on

1 1

Questions about float-point numbers

I roughly know how float point system works. But I don't know why the second looks normal?

If I run

console.log(1.01+2.05);
console.log(1.01+2.05+4.21);
Enter fullscreen mode Exit fullscreen mode

I'll get

3.0599999999999996
7.27
Enter fullscreen mode Exit fullscreen mode

Also, I see some people multiply the number by 100 and add them up, finally divide it by 100. Doesn't this solution have any problem? What if the number is really big? There's overflow concern, isn't it?

Top comments (0)

Image of Docusign

🛠️ Bring your solution into Docusign. Reach over 1.6M customers.

Docusign is now extensible. Overcome challenges with disconnected products and inaccessible data by bringing your solutions into Docusign and publishing to 1.6M customers in the App Center.

Learn more