Mathjs: negative BigNumber values always return in exponential notation

Created on 8 Jan 2019  路  2Comments  路  Source: josdejong/mathjs

negative BigNumber values always return in exponential notation ignoring formatOptions. I expect 1-2 = -1, but it returns 1-2 = -1e+0

let bigmath = math.create({
      number: "BigNumber" 
})

  const formatOptions = {
      notation: "auto", // 'auto', 'fixed', 'exponential' and "engineering"
      fraction: "decimal", //'ratio', 'decimal',
      precision: 99,
      lowerExp: -99,
      upperExp: 99
    }
let answer=bigmath.eval("1-2")
bigmath.format(answer, formatOptions)

You can try it here on codesanbox.

bug

Most helpful comment

This should be fixed now in v5.4.1.

All 2 comments

Thanks for reporting @husayt! Fixed via https://github.com/josdejong/mathjs/commit/0721626422834be78b14fd40f9652b71e45936b8 (will do a release within a few days)

This should be fixed now in v5.4.1.

Was this page helpful?
0 / 5 - 0 ratings

Related issues

balagge picture balagge  路  5Comments

zzzgit picture zzzgit  路  4Comments

adamazing picture adamazing  路  4Comments

lwirtz picture lwirtz  路  3Comments

Lakedaemon picture Lakedaemon  路  5Comments