File tree Expand file tree Collapse file tree 3 files changed +7
-10
lines changed
lib/node_modules/@stdlib/math/base/special/factorial2 Expand file tree Collapse file tree 3 files changed +7
-10
lines changed Original file line number Diff line number Diff line change 21
21
// MODULES //
22
22
23
23
var isnan = require ( '@stdlib/math/base/assert/is-nan' ) ;
24
- var isInteger = require ( '@stdlib/math/base/assert/is-integer' ) ;
24
+ var isNonnegativeInteger = require ( '@stdlib/math/base/assert/is-nonnegative -integer' ) ;
25
25
var isEven = require ( '@stdlib/math/base/assert/is-even' ) ;
26
26
var PINF = require ( '@stdlib/constants/float64/pinf' ) ;
27
27
var FLOAT64_MAX_NTH_DOUBLE_FACTORIAL = require ( '@stdlib/constants/float64/max-nth-double-factorial' ) ; // eslint-disable-line id-length
@@ -56,15 +56,12 @@ function factorial2( n ) {
56
56
var out ;
57
57
var v ;
58
58
var i ;
59
- if ( isnan ( n ) ) {
59
+ if ( isnan ( n ) || ! isNonnegativeInteger ( n ) ) {
60
60
return NaN ;
61
61
}
62
62
if ( n > FLOAT64_MAX_NTH_DOUBLE_FACTORIAL ) {
63
63
return PINF ;
64
64
}
65
- if ( n < 0 || isInteger ( n ) === false ) {
66
- return NaN ;
67
- }
68
65
v = n | 0 ; // asm type annotation
69
66
if ( v === 0 | 0 || v === 1 | 0 ) {
70
67
return 1 | 0 ; // asm type annotation
Original file line number Diff line number Diff line change 40
40
" @stdlib/math/base/assert/is-even" ,
41
41
" @stdlib/constants/float64/pinf" ,
42
42
" @stdlib/constants/float64/max-nth-double-factorial" ,
43
- " @stdlib/math/base/assert/is-integer"
43
+ " @stdlib/math/base/assert/is-nonnegative- integer"
44
44
]
45
45
},
46
46
{
57
57
" @stdlib/math/base/assert/is-even" ,
58
58
" @stdlib/constants/float64/pinf" ,
59
59
" @stdlib/constants/float64/max-nth-double-factorial" ,
60
- " @stdlib/math/base/assert/is-integer"
60
+ " @stdlib/math/base/assert/is-nonnegative- integer"
61
61
]
62
62
},
63
63
{
74
74
" @stdlib/math/base/assert/is-even" ,
75
75
" @stdlib/constants/float64/pinf" ,
76
76
" @stdlib/constants/float64/max-nth-double-factorial" ,
77
- " @stdlib/math/base/assert/is-integer"
77
+ " @stdlib/math/base/assert/is-nonnegative- integer"
78
78
]
79
79
}
80
80
]
Original file line number Diff line number Diff line change 18
18
19
19
#include "stdlib/math/base/special/factorial2.h"
20
20
#include "stdlib/math/base/assert/is_even.h"
21
- #include "stdlib/math/base/assert/is_integer .h"
21
+ #include "stdlib/math/base/assert/is_nonnegative_integer .h"
22
22
#include "stdlib/constants/float64/pinf.h"
23
23
#include "stdlib/constants/float64/max_nth_double_factorial.h"
24
24
@@ -37,7 +37,7 @@ double stdlib_base_factorial2( const double n ) {
37
37
double out ;
38
38
double v ;
39
39
double i ;
40
- if ( !stdlib_base_is_integer ( n ) || n < 0.0 ) {
40
+ if ( !stdlib_base_is_nonnegative_integer ( n ) ) {
41
41
return 0.0 / 0.0 ; // NaN
42
42
}
43
43
if ( n > STDLIB_CONSTANT_FLOAT64_MAX_NTH_DOUBLE_FACTORIAL ) {
You can’t perform that action at this time.
0 commit comments