Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[Feature Request]: support truncated function to cut off mantissa #108

Closed
axetroy opened this issue Oct 12, 2018 · 1 comment
Closed

[Feature Request]: support truncated function to cut off mantissa #108

axetroy opened this issue Oct 12, 2018 · 1 comment

Comments

@axetroy
Copy link

axetroy commented Oct 12, 2018

Fake API

const number = 12.3456
new Big(number).truncate(3) // 12.345 truncate 3 decimal places
number.toFixed(3) // 12.346 rounding
@MikeMcl
Copy link
Owner

MikeMcl commented Oct 12, 2018

See round and Big.RM.

const number = 12.3456
Big.RM = 0    // ROUND_DOWN i.e. truncate
new Big(number).round(3)    // 12.345
number.toFixed(3)    // 12.345

or leave Big.RM alone and pass a rounding mode

const number = 12.3456
const truncate = 0
new Big(number).round(3, truncate)    // 12.345

@MikeMcl MikeMcl closed this as completed Oct 18, 2018
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants