simple-squiggle

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

sign.md (1021B)


      1 <!-- Note: This file is automatically generated from source code comments. Changes made in this file will be overridden. -->
      2 
      3 # Function sign
      4 
      5 Compute the sign of a value. The sign of a value x is:
      6 
      7 -  1 when x > 0
      8 - -1 when x < 0
      9 -  0 when x == 0
     10 
     11 For matrices, the function is evaluated element wise.
     12 
     13 
     14 ## Syntax
     15 
     16 ```js
     17 math.sign(x)
     18 ```
     19 
     20 ### Parameters
     21 
     22 Parameter | Type | Description
     23 --------- | ---- | -----------
     24 `x` | number &#124; BigNumber &#124; Fraction &#124; Complex &#124; Array &#124; Matrix &#124; Unit |  The number for which to determine the sign
     25 
     26 ### Returns
     27 
     28 Type | Description
     29 ---- | -----------
     30 number &#124; BigNumber &#124; Fraction &#124; Complex &#124; Array &#124; Matrix &#124; Unit | e The sign of `x`
     31 
     32 
     33 ### Throws
     34 
     35 Type | Description
     36 ---- | -----------
     37 
     38 
     39 ## Examples
     40 
     41 ```js
     42 math.sign(3.5)               // returns 1
     43 math.sign(-4.2)              // returns -1
     44 math.sign(0)                 // returns 0
     45 
     46 math.sign([3, 5, -2, 0, 2])  // returns [1, 1, -1, 0, 1]
     47 ```
     48 
     49 
     50 ## See also
     51 
     52 [abs](abs.md)