openexchangerates / accounting.js

A lightweight JavaScript library for number, money and currency formatting - fully localisable, zero dependencies.
http://openexchangerates.github.io/accounting.js
MIT License
4.95k stars 528 forks source link

logical error #109

Open vikram06 opened 8 years ago

vikram06 commented 8 years ago

100+1 = 1001 i also enclosed the screen shot... account

Lakshmi-Sharma commented 8 years ago

@vikram06 The example does not evaluate your input, it just treats it as a string.

If you pass "100+1" as a string to formatMoney, i.e. accounting.formatMoney('100+1') it will return "1,001.00". This is because any non numeric input will be unformatted before it is processed, and unformatting removes any unnecessary symbols. This may be by design, it can be useful to remove extra symbols in a number of situations.

I think they should just specify that your input will be treated as string in the docs.