FazBrowse GitHub Viewer
|
Trending
|
URL:
|
Home
Tools:
[Download Repo ZIP]
[View Raw Code]
[Original HTTPS Page]
mathjs/src/function/utils/isNegative.js at develop · imaGuru/mathjs · GitHub
imaGuru
/
mathjs
Public
forked from
josdejong/mathjs
Notifications
You must be signed in to change notification settings
Fork
0
Star
0
Code
Pull requests
0
Actions
Projects
Security and quality
0
Insights
Additional navigation options
Code
Pull requests
Actions
Projects
Security and quality
Insights
Expand file tree
Breadcrumbs
mathjs
/
src
/
function
/
utils
/
isNegative.js
Copy path
More file actions
More file actions
Latest commit
History
History
History
59 lines (52 loc) · 1.82 KB
Breadcrumbs
mathjs
/
src
/
function
/
utils
/
isNegative.js
Copy path
File metadata and controls
59 lines (52 loc) · 1.82 KB
Raw
Copy raw file
Download raw file
Open symbols panel
Edit and raw actions
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
import
{
deepMap
}
from
'../../utils/collection'
import
{
factory
}
from
'../../utils/factory'
import
{
isNegativeNumber
}
from
'../../plain/number'
const
name
=
'isNegative'
const
dependencies
=
[
'typed'
]
export
const
createIsNegative
=
/* #__PURE__ */
factory
(
name
,
dependencies
,
(
{
typed
}
)
=>
{
/**
* Test whether a value is negative: smaller than zero.
* The function supports types `number`, `BigNumber`, `Fraction`, and `Unit`.
*
* The function is evaluated element-wise in case of Array or Matrix input.
*
* Syntax:
*
* math.isNegative(x)
*
* Examples:
*
* math.isNegative(3) // returns false
* math.isNegative(-2) // returns true
* math.isNegative(0) // returns false
* math.isNegative(-0) // returns false
* math.isNegative(math.bignumber(2)) // returns false
* math.isNegative(math.fraction(-2, 5)) // returns true
* math.isNegative('-2') // returns true
* math.isNegative([2, 0, -3]') // returns [false, false, true]
*
* See also:
*
* isNumeric, isPositive, isZero, isInteger
*
*
@param
{
number | BigNumber | Fraction | Unit | Array | Matrix
} x Value to be tested
*
@return
{
boolean
} Returns true when `x` is larger than zero.
* Throws an error in case of an unknown data type.
*/
const
isNegative
=
typed
(
name
,
{
number
:
isNegativeNumber
,
BigNumber
:
function
(
x
)
{
return
x
.
isNeg
(
)
&&
!
x
.
isZero
(
)
&&
!
x
.
isNaN
(
)
}
,
Fraction
:
function
(
x
)
{
return
x
.
s
<
0
// It's enough to decide on the sign
}
,
Unit
:
function
(
x
)
{
return
isNegative
(
x
.
value
)
}
,
'Array | Matrix'
:
function
(
x
)
{
return
deepMap
(
x
,
isNegative
)
}
}
)
return
isNegative
}
)
Back
|
FazBrowse Home
|
New Git URL