Has anyone here used `bignumber.js` in NetSuite ?
# suitescript
j
Has anyone here used
bignumber.js
in NetSuite ?
o
Hey @jen! It’s used SCA and we’ve leveraged it a bit in some of our customisations. Not sure if we’ve used it as a library on any of our Scripts in NetSuite though.
j
Hey Ori, good to hear from you!
I'm going to try to use it as a module how we are already using moment.js Getting tired of JS doing stupid things with numbers
Example:
message has been deleted
o
Nice to touch base! Hope you’re doing well 🙂 Yep, I see 🙃 It’s a nice library. The one gotcha we’ve experienced using it was an error where it thinks a number has too many significant digits. E.g.:
new BigNumber() number type has more than 15 significant digits: ...
The way to handle it was to call
toString
on the var containing the value you’re referencing. E.g.:
new BigNumber(retailPrice.toString()).toFixed(2);
s
I have used its smaller sibling,
big.js
, and it has worked well in several projects. I think
bignumber.js
is a more full featured version
d
Ya, just use big.js