mathjs
Version:
Math.js is an extensive math library for JavaScript and Node.js. It features a flexible expression parser and offers an integrated solution to work with numbers, big numbers, complex numbers, units, and matrices.
49 lines (32 loc) • 1.01 kB
Markdown
Create a unit. Depending on the passed arguments, the function
will create and return a new math.type.Unit object.
When a matrix is provided, all elements will be converted to units.
```js
math.unit(unit : string)
math.unit(value : number, unit : string)
```
Parameter | Type | Description
--------- | ---- | -----------
`args` | * &
Type | Description
---- | -----------
Unit &
```js
var a = math.unit(5, 'cm'); // returns Unit 50 mm
var b = math.unit('23 kg'); // returns Unit 23 kg
a.to('m'); // returns Unit 0.05 m
```
[](bignumber.md),
[](boolean.md),
[](complex.md),
[](index.md),
[](matrix.md),
[](number.md),
[](string.md)
<!-- Note: This file is automatically generated from source code comments. Changes made in this file will be overridden. -->