simple-squiggle

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

numeric.md (1330B)


      1 <!-- Note: This file is automatically generated from source code comments. Changes made in this file will be overridden. -->
      2 
      3 # Function numeric
      4 
      5 Convert a numeric input to a specific numeric type: number, BigNumber, or Fraction.
      6 
      7 
      8 ## Syntax
      9 
     10 ```js
     11 math.numeric(x)
     12 ```
     13 
     14 ### Parameters
     15 
     16 Parameter | Type | Description
     17 --------- | ---- | -----------
     18 `value` | string &#124; number &#124; BigNumber &#124; Fraction |  A numeric value or a string containing a numeric value
     19 `outputType` | string |  Desired numeric output type. Available values: 'number', 'BigNumber', or 'Fraction'
     20 
     21 ### Returns
     22 
     23 Type | Description
     24 ---- | -----------
     25 number &#124; BigNumber &#124; Fraction |  Returns an instance of the numeric in the requested type
     26 
     27 
     28 ### Throws
     29 
     30 Type | Description
     31 ---- | -----------
     32 
     33 
     34 ## Examples
     35 
     36 ```js
     37 math.numeric('4')                           // returns number 4
     38 math.numeric('4', 'number')                 // returns number 4
     39 math.numeric('4', 'BigNumber')              // returns BigNumber 4
     40 math.numeric('4', 'Fraction')               // returns Fraction 4
     41 math.numeric(4, 'Fraction')                 // returns Fraction 4
     42 math.numeric(math.fraction(2, 5), 'number') // returns number 0.4
     43 ```
     44 
     45 
     46 ## See also
     47 
     48 [number](number.md),
     49 [fraction](fraction.md),
     50 [bignumber](bignumber.md),
     51 [string](string.md),
     52 [format](format.md)