1 |
|
2 |
|
3 | # Function isPositive
|
4 |
|
5 | Test whether a value is positive: larger than zero.
|
6 | The function supports types `number`, `BigNumber`, `Fraction`, and `Unit`.
|
7 |
|
8 | The function is evaluated element-wise in case of Array or Matrix input.
|
9 |
|
10 |
|
11 | ## Syntax
|
12 |
|
13 | ```js
|
14 | math.isPositive(x)
|
15 | ```
|
16 |
|
17 | ### Parameters
|
18 |
|
19 | Parameter | Type | Description
|
20 | --------- | ---- | -----------
|
21 | `x` | number | BigNumber | Fraction | Unit | Array | Matrix | Value to be tested
|
22 |
|
23 | ### Returns
|
24 |
|
25 | Type | Description
|
26 | ---- | -----------
|
27 | boolean | Returns true when `x` is larger than zero. Throws an error in case of an unknown data type.
|
28 |
|
29 |
|
30 | ## Examples
|
31 |
|
32 | ```js
|
33 | math.isPositive(3) // returns true
|
34 | math.isPositive(-2) // returns false
|
35 | math.isPositive(0) // returns false
|
36 | math.isPositive(-0) // returns false
|
37 | math.isPositive(0.5) // returns true
|
38 | math.isPositive(math.bignumber(2)) // returns true
|
39 | math.isPositive(math.fraction(-2, 5)) // returns false
|
40 | math.isPositive(math.fraction(1,3)) // returns false
|
41 | math.isPositive('2') // returns true
|
42 | math.isPositive([2, 0, -3]) // returns [true, false, false]
|
43 | ```
|
44 |
|
45 |
|
46 | ## See also
|
47 |
|
48 | [isNumeric](isNumeric.md),
|
49 | [isZero](isZero.md),
|
50 | [isNegative](isNegative.md),
|
51 | [isInteger](isInteger.md)
|