函数 #
更改值的单位。
对于矩阵,该函数逐元素求值。
Syntax #
math.to(x, unit)
Parameters #
| Parameter | Type | Description |
|---|---|---|
x |
单位 | 数组 | 矩阵 | 要转换的单位。 |
unit |
单位 | 数组 | 矩阵 | 新单位。可以是像“cm”这样的字符串,或者是不带值的单位。 |
Returns #
| Type | Description |
|---|---|
| 单位 | 数组 | 矩阵 | 已更改、固定单位的值。 |
Throws #
Type | Description —- | ———–
Examples #
math.to(math.unit('2 inch'), 'cm') // returns Unit 5.08 cm
math.to(math.unit('2 inch'), math.unit('cm')) // returns Unit 5.08 cm
math.to(math.unit(16, 'bytes'), 'bits') // returns Unit 128 bits