simple-squiggle

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

fix.md (1526B)


      1 <!-- Note: This file is automatically generated from source code comments. Changes made in this file will be overridden. -->
      2 
      3 # Function fix
      4 
      5 Round a value towards zero.
      6 For matrices, the function is evaluated element wise.
      7 
      8 
      9 ## Syntax
     10 
     11 ```js
     12 math.fix(x)
     13 ```
     14 
     15 ### Parameters
     16 
     17 Parameter | Type | Description
     18 --------- | ---- | -----------
     19 `x` | number &#124; BigNumber &#124; Fraction &#124; Complex &#124; Array &#124; Matrix | Number to be rounded
     20 `n` | number &#124; BigNumber &#124; Array | Number of decimals Default value: 0.
     21 
     22 ### Returns
     23 
     24 Type | Description
     25 ---- | -----------
     26 number &#124; BigNumber &#124; Fraction &#124; Complex &#124; Array &#124; Matrix | Rounded value
     27 
     28 
     29 ### Throws
     30 
     31 Type | Description
     32 ---- | -----------
     33 
     34 
     35 ## Examples
     36 
     37 ```js
     38 math.fix(3.2)                // returns number 3
     39 math.fix(3.8)                // returns number 3
     40 math.fix(-4.2)               // returns number -4
     41 math.fix(-4.7)               // returns number -4
     42 
     43 math.fix(3.12, 1)                // returns number 3.1
     44 math.fix(3.18, 1)                // returns number 3.1
     45 math.fix(-4.12, 1)               // returns number -4.1
     46 math.fix(-4.17, 1)               // returns number -4.1
     47 
     48 const c = math.complex(3.22, -2.78)
     49 math.fix(c)                  // returns Complex 3 - 2i
     50 math.fix(c, 1)               // returns Complex 3.2 - 2.7i
     51 
     52 math.fix([3.2, 3.8, -4.7])      // returns Array [3, 3, -4]
     53 math.fix([3.2, 3.8, -4.7], 1)   // returns Array [3.2, 3.8, -4.7]
     54 ```
     55 
     56 
     57 ## See also
     58 
     59 [ceil](ceil.md),
     60 [floor](floor.md),
     61 [round](round.md)