# Playing with numbers in JavaScript

Today I did a bit a JavaScript to test some librairies to manipulate numbers.

The first is BigDecimal. It is based on the GWT implementation of Java BigDecimal class. It works exactly the its Java counterpart. If your doing financial calculation in JavaScript, this library is a must.

Then, I tried Numeral.js. A library allowing to format numbers easily in a given locale. Easy to use and works perfectly.

The last one was Formula.js. This one is fun and useful. It re-implements all Excel functions in JavaScript. They are two drawbacks.

The first one is that you need to add a bunch of other libraries to use it. But depending on which function you are using, you might not need all of them but that's left to you to figure it out.

The second one is that it calls eval in some function parameters. Could be dangerous so beware.

My suggestion on this library is to copy & paste the code of the functions you are using to limit the required third-party libraries, tweak it a bit to remove the evals and possibly migrate it to BigDecimal ;-)

The first is BigDecimal. It is based on the GWT implementation of Java BigDecimal class. It works exactly the its Java counterpart. If your doing financial calculation in JavaScript, this library is a must.

Then, I tried Numeral.js. A library allowing to format numbers easily in a given locale. Easy to use and works perfectly.

The last one was Formula.js. This one is fun and useful. It re-implements all Excel functions in JavaScript. They are two drawbacks.

The first one is that you need to add a bunch of other libraries to use it. But depending on which function you are using, you might not need all of them but that's left to you to figure it out.

The second one is that it calls eval in some function parameters. Could be dangerous so beware.

My suggestion on this library is to copy & paste the code of the functions you are using to limit the required third-party libraries, tweak it a bit to remove the evals and possibly migrate it to BigDecimal ;-)