File tree 5 files changed +13
-15
lines changed
lib/node_modules/@stdlib/math/base/special/factorial2
include/stdlib/math/base/special
5 files changed +13
-15
lines changed Original file line number Diff line number Diff line change @@ -130,10 +130,10 @@ double out = stdlib_base_factorial2( 3 );
130
130
131
131
The function accepts the following arguments:
132
132
133
- - ** x ** : ` [in] int32_t ` input value.
133
+ - ** n ** : ` [in] int32_t ` input value.
134
134
135
135
``` c
136
- double stdlib_base_factorial2 ( const int32_t x );
136
+ double stdlib_base_factorial2 ( const int32_t n );
137
137
```
138
138
139
139
</section>
Original file line number Diff line number Diff line change @@ -31,7 +31,7 @@ extern "C" {
31
31
/**
32
32
* Evaluates the double factorial of `n`.
33
33
*/
34
- double stdlib_base_factorial2 ( const int32_t x );
34
+ double stdlib_base_factorial2 ( const int32_t n );
35
35
36
36
#ifdef __cplusplus
37
37
}
Original file line number Diff line number Diff line change @@ -24,11 +24,7 @@ var isnan = require( '@stdlib/math/base/assert/is-nan' );
24
24
var isInteger = require ( '@stdlib/math/base/assert/is-integer' ) ;
25
25
var isEven = require ( '@stdlib/math/base/assert/is-even' ) ;
26
26
var PINF = require ( '@stdlib/constants/float64/pinf' ) ;
27
-
28
-
29
- // VARIABLES //
30
-
31
- var MAX_FACTORIAL2 = 301 ; // TODO: consider extracting as a constant
27
+ var FLOAT64_MAX_SAFE_NTH_DOUBLE_FACTORIAL = require ( '@stdlib/constants/float64/max-safe-nth-double-factorial' ) ; // eslint-disable-line id-length
32
28
33
29
34
30
// MAIN //
@@ -63,7 +59,7 @@ function factorial2( n ) {
63
59
if ( isnan ( n ) ) {
64
60
return NaN ;
65
61
}
66
- if ( n >= MAX_FACTORIAL2 ) {
62
+ if ( n > FLOAT64_MAX_SAFE_NTH_DOUBLE_FACTORIAL ) {
67
63
return PINF ;
68
64
}
69
65
if ( n < 0 || isInteger ( n ) === false ) {
Original file line number Diff line number Diff line change 40
40
" @stdlib/math/base/assert/is-nan" ,
41
41
" @stdlib/math/base/assert/is-integer" ,
42
42
" @stdlib/math/base/assert/is-even" ,
43
- " @stdlib/constants/float64/pinf"
43
+ " @stdlib/constants/float64/pinf" ,
44
+ " @stdlib/constants/float64/max-safe-nth-double-factorial"
44
45
]
45
46
},
46
47
{
57
58
" @stdlib/math/base/assert/is-nan" ,
58
59
" @stdlib/math/base/assert/is-integer" ,
59
60
" @stdlib/math/base/assert/is-even" ,
60
- " @stdlib/constants/float64/pinf"
61
+ " @stdlib/constants/float64/pinf" ,
62
+ " @stdlib/constants/float64/max-safe-nth-double-factorial"
61
63
]
62
64
},
63
65
{
74
76
" @stdlib/math/base/assert/is-nan" ,
75
77
" @stdlib/math/base/assert/is-integer" ,
76
78
" @stdlib/math/base/assert/is-even" ,
77
- " @stdlib/constants/float64/pinf"
79
+ " @stdlib/constants/float64/pinf" ,
80
+ " @stdlib/constants/float64/max-safe-nth-double-factorial"
78
81
]
79
82
}
80
83
]
Original file line number Diff line number Diff line change 21
21
#include "stdlib/math/base/assert/is_integer.h"
22
22
#include "stdlib/math/base/assert/is_even.h"
23
23
#include "stdlib/constants/float64/pinf.h"
24
+ #include "stdlib/constants/float64/max_safe_nth_double_factorial.h"
24
25
#include <stdint.h>
25
26
26
- #define MAX_FACTORIAL2 301
27
-
28
27
/**
29
28
* Evaluates the double factorial of `n`.
30
29
*
@@ -43,7 +42,7 @@ double stdlib_base_factorial2( const int32_t n ) {
43
42
if ( stdlib_base_is_nan ( n ) ) {
44
43
return 0.0 /0.0 ; // NaN
45
44
}
46
- if ( n >= MAX_FACTORIAL2 ) {
45
+ if ( n > STDLIB_CONSTANT_FLOAT64_MAX_SAFE_NTH_DOUBLE_FACTORIAL ) {
47
46
return STDLIB_CONSTANT_FLOAT64_PINF ;
48
47
}
49
48
if ( n < 0 || !stdlib_base_is_integer ( n ) ) {
You can’t perform that action at this time.
0 commit comments