CloseQuotely has a free estimate template: a page where a contractor types lines, quantities and prices, sees a total and prints it. No account, nothing saved on our side. It's a marketing page, and it would be easy to write its math in ten minutes with parseFloat .
We didn't, because the app's real quotes use the same lines, and a free page that's a cent off the product is a bad first impression. So the page imports the product's own quote math. Here's what that math does differently.
Floats get money wrong in ordinary cases
parseFloat ( "1.15" ) * 100 // 114.99999999999999 Math . round ( 1.005 * 100 ) / 100 // 1, not 1.01 0.1 + 0.2 // 0.30000000000000004
Enter fullscreen mode
Exit fullscreen mode
The first one is the dangerous one: floor it to get cents and $1.15 becomes $1.14.
Parse text straight into integers
Money is integer cents, and it never passes through a float.…