-
Notifications
You must be signed in to change notification settings - Fork 320
Conversation
I'm in favor of dropping num (because it's a risk from the perspective of canonical popularity), but do you have any benchmark metrics to prove this claim? Personally, I'd love to see a benchmark comparison between num, decimal.js, big.js, and bignumber.js.
|
This got me searching. Interestingly, while decimal.js was written to be "v2" of bigdecimal.js, the author of both claims that bigdecimal.js is potentially better for financial applications; whereas, decimal.js is potentially better for scientific applications: https://github.com/MikeMcl/big.js/wiki
Though, the author also claims that decimal.js is faster than bignumer.js: https://github.com/MikeMcl/decimal.js/#features
|
I could provide metrics for |
I just did 2 runs each to time
|
Very nice! However, given that decimal.js only handles precision rounding (significant digits), but bignumber.js handles decimal place rounding, I think bignumber.js is a much better fit for a cryptocurrency/financial library. Thoughts? |
Changed to |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM.
The only nit I have is that, by default, BigNumber
is configured for 20 decimal places, but GDAX is limited to 8 decimal places. I think it would probably be safe to configure BigNumber
with 10 decimal places (to account for rounding during potential mathematical operations -- even though none of those exist in the library just yet).
BigNumber.config({ DECIMAL_PLACES: 10 })
BigNumber is also what GDAX Trading Toolkit uses, so that consistency between Coinbase projects would be nice. (my 2¢) |
This looks great. I agree that we should probably switch to another library — BigNumber or Big.js would both be two great options. |
Missed the update — great addition, thanks a lot! |
I was loading a lot of a data and noticed that the
num
library was slow. I gavedecimal.js
a shot and it's significantly faster.