Function config #

设置 math.js 的配置选项,并获取当前选项。会触发一个 ‘config’ 事件,参数为 (curr, prev, changes)。

此函数仅在使用了 create 创建的 mathjs 实例上可用。

Syntax #

math.config(config: Object): Object

Parameters #

Parameter Type Description
options Object 可用选项:{number} relTol 两个比较值之间的最小相对差值,所有比较函数都会使用。{number} absTol 两个比较值之间的最小绝对差值,所有比较函数都会使用。{string} matrix 字符串 ‘Matrix’ (默认) 或 ‘Array’。{string} number 字符串 ‘number’ (默认)、‘BigNumber’、‘bigint’ 或 ‘Fraction’ {number} precision BigNumbers 的有效数字位数。不适用于 Numbers。{string} parenthesis LaTeX 和字符串输出中如何显示括号。{string} randomSeed 伪随机数生成器的随机种子。设置为 null 则随机生成种子。

Returns #

Type Description
Object 返回当前配置

Throws #

Type | Description —- | ———–

Examples #

import { create, all } from 'mathjs'

// create a mathjs instance
const math = create(all)

math.config().number                // outputs 'number'
math.evaluate('0.4')                // outputs number 0.4
math.config({number: 'Fraction'})
math.evaluate('0.4')                // outputs Fraction 2/5
Fork me on GitHub