toFormat icon indicating copy to clipboard operation
toFormat copied to clipboard

toFormat not respecting 'rm' passed in

Open juviasuisei opened this issue 4 years ago • 2 comments

I expected it to just inherit from the Decimal config (unsure if the fact that it didn't is itself another bug) but even when I passed in a rm explicitly it ignored it.

Code samples of the problem (I'm running Decimal 10.2.0 and toFormat 2.0.0):

Decimal.set({'rounding': 6}); toFormat(Decimal); n = new Decimal('1234.5'); n.toFormat() Expected: 1,234 Result: 1,235

n.toFormat(0, rm=6) Expected: 1,234 Result: 1,235

Let me know if there is anything I can do to help troubleshoot! Thank you!

juviasuisei avatar Sep 02 '20 03:09 juviasuisei

I tried your code and the result is as expected:

const Decimal = require('decimal.js')
const toFormat = require('toformat');
const log = console.log;

Decimal.set({'rounding': 6});
toFormat(Decimal);
n = new Decimal('1234.5');
log(n.toFormat());           // "1,234.5"
log(n.toFormat(0, rm=6));    // "1,234"

MikeMcl avatar Sep 03 '20 22:09 MikeMcl

Hmm. I'll try again today in a fresh file to see if maybe something else is interacting with it. Also this is happening client-side for me in Safari 13.1.2.

juviasuisei avatar Sep 04 '20 13:09 juviasuisei