Javascript FAQ
Float precision
1 | console.log(0.1 + 0.2) // 0.30000000000000004 |
Solution: Strip
1 | function strip(number) { |
Solution: Decimal.js
- The
decimal.js
package is 283kb at the time of writing. Sodecimal.js
is not appropriate for frontend.
1 | const Decimal = require('decimal.js') |
Javascript FAQ