File tree Expand file tree Collapse file tree 5 files changed +13
-15
lines changed
lib/node_modules/@stdlib/math/base/special/factorial2
include/stdlib/math/base/special Expand file tree Collapse file tree 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 );
130130
131131The function accepts the following arguments:
132132
133- - ** x ** : ` [in] int32_t ` input value.
133+ - ** n ** : ` [in] int32_t ` input value.
134134
135135``` c
136- double stdlib_base_factorial2 ( const int32_t x );
136+ double stdlib_base_factorial2 ( const int32_t n );
137137```
138138
139139</section>
Original file line number Diff line number Diff line change @@ -31,7 +31,7 @@ extern "C" {
3131/**
3232* Evaluates the double factorial of `n`.
3333*/
34- double stdlib_base_factorial2 ( const int32_t x );
34+ double stdlib_base_factorial2 ( const int32_t n );
3535
3636#ifdef __cplusplus
3737}
Original file line number Diff line number Diff line change @@ -24,11 +24,7 @@ var isnan = require( '@stdlib/math/base/assert/is-nan' );
2424var isInteger = require ( '@stdlib/math/base/assert/is-integer' ) ;
2525var isEven = require ( '@stdlib/math/base/assert/is-even' ) ;
2626var 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
3228
3329
3430// MAIN //
@@ -63,7 +59,7 @@ function factorial2( n ) {
6359 if ( isnan ( n ) ) {
6460 return NaN ;
6561 }
66- if ( n >= MAX_FACTORIAL2 ) {
62+ if ( n > FLOAT64_MAX_SAFE_NTH_DOUBLE_FACTORIAL ) {
6763 return PINF ;
6864 }
6965 if ( n < 0 || isInteger ( n ) === false ) {
Original file line number Diff line number Diff line change 4040 " @stdlib/math/base/assert/is-nan" ,
4141 " @stdlib/math/base/assert/is-integer" ,
4242 " @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"
4445 ]
4546 },
4647 {
5758 " @stdlib/math/base/assert/is-nan" ,
5859 " @stdlib/math/base/assert/is-integer" ,
5960 " @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"
6163 ]
6264 },
6365 {
7476 " @stdlib/math/base/assert/is-nan" ,
7577 " @stdlib/math/base/assert/is-integer" ,
7678 " @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"
7881 ]
7982 }
8083 ]
Original file line number Diff line number Diff line change 2121#include "stdlib/math/base/assert/is_integer.h"
2222#include "stdlib/math/base/assert/is_even.h"
2323#include "stdlib/constants/float64/pinf.h"
24+ #include "stdlib/constants/float64/max_safe_nth_double_factorial.h"
2425#include <stdint.h>
2526
26- #define MAX_FACTORIAL2 301
27-
2827/**
2928* Evaluates the double factorial of `n`.
3029*
@@ -43,7 +42,7 @@ double stdlib_base_factorial2( const int32_t n ) {
4342 if ( stdlib_base_is_nan ( n ) ) {
4443 return 0.0 /0.0 ; // NaN
4544 }
46- if ( n >= MAX_FACTORIAL2 ) {
45+ if ( n > STDLIB_CONSTANT_FLOAT64_MAX_SAFE_NTH_DOUBLE_FACTORIAL ) {
4746 return STDLIB_CONSTANT_FLOAT64_PINF ;
4847 }
4948 if ( n < 0 || !stdlib_base_is_integer ( n ) ) {
You can’t perform that action at this time.
0 commit comments