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

How to round to the nearest even number? #102

Closed kramer65 closed 9 years ago

kramer65 commented 9 years ago

When displaying a currency amount I want to use the bankersround: always round to the closes even value when rounding a 5. So like this:

0.255 => 0.26
0.265 => 0.26
0.275 => 0.28
0.285 => 0.28

Does anybody know if this is possible with accounting.js? All tips are welcome!

ghost commented 9 years ago

Unfortunately, at the moment you will have to round your numbers before you pass them into accounting.js.

kramer65 commented 9 years ago

Ah, in that case I'll round them in Big.js before I pass them on to accounting.js.

Thanks a million for the info!