MikeMcl / decimal.js

An arbitrary-precision Decimal type for JavaScript
http://mikemcl.github.io/decimal.js
MIT License
6.35k stars 480 forks source link

Support for mathematical expression processing without loss of precision #229

Closed admincopm closed 10 months ago

admincopm commented 10 months ago

Support for mathematical expression processing without loss of precision

josdejong commented 10 months ago

You can do that with mathjs, which uses decimal.js under the hood when you configure it to use BigNumber:

import { create, all } from 'mathjs'

const config = { 
  number: 'BigNumber', 
  precision: 64 
}
const math = create(all, config)

const result = math.evaluate('0.1 + 0.2') // BigNumber 0.3
console.log(result.toString())
admincopm commented 10 months ago

Yes, I am currently using math.js to process mathematical expressions