DEV Community

Discussion on: Dealing with Floating Point Numbers in JavaScript: Lessons Learned

Collapse
 
jonrandy profile image
Jon Randy 🎖️

Never store money in floating point numbers. Recipe for disaster. Integers almost always the safest way

Collapse
 
kyosifov profile image
Kaloyan Yosifov

That's right!

We do not store floating point numbers in the database, but on the frontend we needed to allow users to change the amount. So for the presentation layer we had to convert from cents to floating point and then when we send the amount, back to the server, to cents.