ramsey/moontoast-math

[Feature request] Implement decimalPlaces method

peter279k opened this issue · 1 comments

As title, and I refer the bignumber.js and this is the JavaScript library. I notice that some methods are useful. Consider the JS code snippets:

var big = require('bignumber.js');
big(0.15).dp(1).toString(); // '0.2'
big(0.15).dp().toString(); // '2'
big(0.15).dp(0).toString(); // '0'

It seems that the method approach is as follows:

  • Give the precision integer and it will round the number with specific precision.
  • If the passed precision integer is zero, the result will return the float number length.

I will be marking this library as "abandoned" in the near future, and I recommend brick/math as a replacement. Thanks!