Skip to content

Commit

Permalink
Fix: #2608: describe changing epsilon when configuring BigNumber.
Browse files Browse the repository at this point in the history
  • Loading branch information
josdejong committed Jun 29, 2022
1 parent ead6228 commit 297d2e0
Show file tree
Hide file tree
Showing 2 changed files with 17 additions and 2 deletions.
6 changes: 6 additions & 0 deletions HISTORY.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,11 @@
# History

# unpublished changes since 10.6.4

- Fix: #2608 clarify the docs on the need to configure a smaller `epsilon`
when using BigNumbers.


# 2022-06-28, version 10.6.4

- Improve TypeScript definitions of the `factory` function, thanks @mattvague.
Expand Down
13 changes: 11 additions & 2 deletions docs/datatypes/bignumbers.md
Original file line number Diff line number Diff line change
Expand Up @@ -23,15 +23,24 @@ BigNumbers instead of [numbers](numbers.md) by default, configure math.js like:
math.config({
number: 'BigNumber', // Default type of number:
// 'number' (default), 'BigNumber', or 'Fraction'
precision: 64 // Number of significant digits for BigNumbers
precision: 64, // Number of significant digits for BigNumbers
epsilon: 1e-60
})

// use math
math.evaluate('0.1 + 0.2') // BigNumber, 0.3
```

The default precision for BigNumber is 64 digits, and can be configured with
the option `precision`.
the option `precision`.

Note that we also change the configuration of `epsilon`
to be close to the precision limit of our BigNumbers. `epsilon` is used for
example in relational and rounding functions (`equal`, `larger`, `smaller`,
`round`, `floor`, etc) to determine when a value is nearly equal,
see [Equality](numbers.md#equality). If we would leave `epsilon` unchanged,
having the default value of `1e-12`, we could get inaccurate and misleading
results since we're now working with a higher precision.


## Support
Expand Down

0 comments on commit 297d2e0

Please sign in to comment.