simple-squiggle

A restricted subset of Squiggle
Log | Files | Refs | README

to.md (971B)


      1 <!-- Note: This file is automatically generated from source code comments. Changes made in this file will be overridden. -->
      2 
      3 # Function to
      4 
      5 Change the unit of a value.
      6 
      7 For matrices, the function is evaluated element wise.
      8 
      9 
     10 ## Syntax
     11 
     12 ```js
     13 math.to(x, unit)
     14 ```
     15 
     16 ### Parameters
     17 
     18 Parameter | 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 
     25 Type | Description
     26 ---- | -----------
     27 Unit &#124; Array &#124; Matrix | value with changed, fixed unit.
     28 
     29 
     30 ### Throws
     31 
     32 Type | Description
     33 ---- | -----------
     34 
     35 
     36 ## Examples
     37 
     38 ```js
     39 math.to(math.unit('2 inch'), 'cm')                   // returns Unit 5.08 cm
     40 math.to(math.unit('2 inch'), math.unit(null, 'cm'))  // returns Unit 5.08 cm
     41 math.to(math.unit(16, 'bytes'), 'bits')              // returns Unit 128 bits
     42 ```
     43 
     44 
     45 ## See also
     46 
     47 [unit](unit.md)