mathjs
Version:
Math.js is an extensive math library for JavaScript and Node.js. It features a flexible expression parser with support for symbolic computation, comes with a large set of built-in functions and constants, and offers an integrated solution to work with dif
50 lines (34 loc) • 1.27 kB
Markdown
<!-- Note: This file is automatically generated from source code comments. Changes made in this file will be overridden. -->
Create a number or convert a string, boolean, or unit to a number.
When value is a matrix, all elements will be converted to number.
```js
math.number(value)
math.number(unit, valuelessUnit)
```
Parameter | Type | Description
--------- | ---- | -----------
`value` | string &
`valuelessUnit` | Unit &
Type | Description
---- | -----------
number &
```js
math.number(2) // returns number 2
math.number('7.2') // returns number 7.2
math.number(true) // returns number 1
math.number([true, false, true, true]) // returns [1, 0, 1, 1]
math.number(math.unit('52cm'), 'm') // returns 0.52
```
[ ](bignumber.md),
[ ](boolean.md),
[ ](complex.md),
[ ](index.md),
[ ](matrix.md),
[ ](string.md),
[ ](unit.md)