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

Wrong rounding on toFixed() for negative numbers #215

Open pgeimer opened 3 years ago

pgeimer commented 3 years ago

toFixed() returns wrong rounded values on negative numbers:

accounting.toFixed(-2.5, 0) // Returns -2 (expected -3)
accounting.toFixed(2.5, 0) // Returns 3

See: https://jsbin.com/himapogoyo/edit?html,js,console