MikeMcl / decimal.js

An arbitrary-precision Decimal type for JavaScript
http://mikemcl.github.io/decimal.js
MIT License
6.35k stars 480 forks source link

Convert Decimaljs to fixed string without trailing zeros #194

Closed MylesWardell closed 2 years ago

MylesWardell commented 2 years ago

I would like to avoid converting my numbers to JS numbers ever but I don't want to add regex to every request where the user sees the number to clear trailing zeros. Could we add a round option or new chain option that converts the decimal to string without trailing zeros?

Example of what I am showing the user. I am not a fan of any of these solutions https://stackoverflow.com/questions/3612744/remove-insignificant-trailing-zeros-from-a-number

MylesWardell commented 2 years ago

.toDecimalPlaces().toString() Just saw the previously closed issue. Closing 👍