FazBrowse GitHub Viewer
|
Trending
|
URL:
|
Home
Tools:
[Download Repo ZIP]
[View Raw Code]
[Original HTTPS Page]
mathjs/src/function/utils/isInteger.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
/
isInteger.js
Copy path
More file actions
More file actions
Latest commit
History
History
History
55 lines (49 loc) · 1.75 KB
Breadcrumbs
mathjs
/
src
/
function
/
utils
/
isInteger.js
Copy path
File metadata and controls
55 lines (49 loc) · 1.75 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
import
{
deepMap
}
from
'../../utils/collection'
import
{
isInteger
as
isIntegerNumber
}
from
'../../utils/number'
import
{
factory
}
from
'../../utils/factory'
const
name
=
'isInteger'
const
dependencies
=
[
'typed'
]
export
const
createIsInteger
=
/* #__PURE__ */
factory
(
name
,
dependencies
,
(
{
typed
}
)
=>
{
/**
* Test whether a value is an integer number.
* The function supports `number`, `BigNumber`, and `Fraction`.
*
* The function is evaluated element-wise in case of Array or Matrix input.
*
* Syntax:
*
* math.isInteger(x)
*
* Examples:
*
* math.isInteger(2) // returns true
* math.isInteger(0) // returns true
* math.isInteger(0.5) // returns false
* math.isInteger(math.bignumber(500)) // returns true
* math.isInteger(math.fraction(4)) // returns true
* math.isInteger('3') // returns true
* math.isInteger([3, 0.5, -2]) // returns [true, false, true]
* math.isInteger(math.complex('2-4i') // throws an error
*
* See also:
*
* isNumeric, isPositive, isNegative, isZero
*
*
@param
{
number | BigNumber | Fraction | Array | Matrix
} x Value to be tested
*
@return
{
boolean
} Returns true when `x` contains a numeric, integer value.
* Throws an error in case of an unknown data type.
*/
const
isInteger
=
typed
(
name
,
{
number
:
isIntegerNumber
,
// TODO: what to do with isInteger(add(0.1, 0.2)) ?
BigNumber
:
function
(
x
)
{
return
x
.
isInt
(
)
}
,
Fraction
:
function
(
x
)
{
return
x
.
d
===
1
&&
isFinite
(
x
.
n
)
}
,
'Array | Matrix'
:
function
(
x
)
{
return
deepMap
(
x
,
isInteger
)
}
}
)
return
isInteger
}
)
Back
|
FazBrowse Home
|
New Git URL