FazBrowse GitHub Viewer
|
Trending
|
URL:
|
Home
Tools:
[Download Repo ZIP]
[View Raw Code]
[Original HTTPS Page]
mathjs/src/function/utils/isZero.js at develop · krishna366/mathjs · GitHub
krishna366
/
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
/
isZero.js
Copy path
More file actions
More file actions
Latest commit
History
History
History
62 lines (55 loc) · 1.99 KB
Breadcrumbs
mathjs
/
src
/
function
/
utils
/
isZero.js
Copy path
File metadata and controls
62 lines (55 loc) · 1.99 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
60
61
62
import
{
deepMap
}
from
'../../utils/collection.js'
import
{
factory
}
from
'../../utils/factory.js'
import
{
isZeroNumber
}
from
'../../plain/number/index.js'
const
name
=
'isZero'
const
dependencies
=
[
'typed'
]
export
const
createIsZero
=
/* #__PURE__ */
factory
(
name
,
dependencies
,
(
{
typed
}
)
=>
{
/**
* Test whether a value is zero.
* The function can check for zero for types `number`, `BigNumber`, `Fraction`,
* `Complex`, and `Unit`.
*
* The function is evaluated element-wise in case of Array or Matrix input.
*
* Syntax:
*
* math.isZero(x)
*
* Examples:
*
* math.isZero(0) // returns true
* math.isZero(2) // returns false
* math.isZero(0.5) // returns false
* math.isZero(math.bignumber(0)) // returns true
* math.isZero(math.fraction(0)) // returns true
* math.isZero(math.fraction(1,3)) // returns false
* math.isZero(math.complex('2 - 4i')) // returns false
* math.isZero(math.complex('0i')) // returns true
* math.isZero('0') // returns true
* math.isZero('2') // returns false
* math.isZero([2, 0, -3]) // returns [false, true, false]
*
* See also:
*
* isNumeric, isPositive, isNegative, isInteger
*
*
@param
{
number | BigNumber | Complex | Fraction | Unit | Array | Matrix
} x Value to be tested
*
@return
{
boolean
} Returns true when `x` is zero.
* Throws an error in case of an unknown data type.
*/
return
typed
(
name
,
{
number
:
isZeroNumber
,
BigNumber
:
function
(
x
)
{
return
x
.
isZero
(
)
}
,
Complex
:
function
(
x
)
{
return
x
.
re
===
0
&&
x
.
im
===
0
}
,
Fraction
:
function
(
x
)
{
return
x
.
d
===
1
&&
x
.
n
===
0
}
,
Unit
:
typed
.
referToSelf
(
self
=>
x
=>
typed
.
find
(
self
,
x
.
valueType
(
)
)
(
x
.
value
)
)
,
'Array | Matrix'
:
typed
.
referToSelf
(
self
=>
x
=>
deepMap
(
x
,
self
)
)
}
)
}
)
Back
|
FazBrowse Home
|
New Git URL