UNPKG

919 BMarkdownView Raw
1<!-- Note: This file is automatically generated from source code comments. Changes made in this file will be overridden. -->
2
3# Function to
4
5Change the unit of a value.
6
7For matrices, the function is evaluated element wise.
8
9
10## Syntax
11
12```js
13math.to(x, unit)
14```
15
16### Parameters
17
18Parameter | Type | Description
19--------- | ---- | -----------
20`x` | Unit &#124; Array &#124; Matrix | The unit to be converted.
21`unit` | Unit &#124; Array &#124; Matrix | New unit. Can be a string like "cm" or a unit without value.
22
23### Returns
24
25Type | Description
26---- | -----------
27Unit &#124; Array &#124; Matrix | value with changed, fixed unit.
28
29
30## Examples
31
32```js
33math.to(math.unit('2 inch'), 'cm') // returns Unit 5.08 cm
34math.to(math.unit('2 inch'), math.unit(null, 'cm')) // returns Unit 5.08 cm
35math.to(math.unit(16, 'bytes'), 'bits') // returns Unit 128 bits
36```
37
38
39## See also
40
41[unit](unit.md)