Skip to content

Commit 3bc9214

Browse files
chore: use FLOAT64_MAX_SAFE_NTH_DOUBLE_FACTORIAL
PR-URL: #6363 Reviewed-by: Philipp Burckhardt <[email protected]>
1 parent 7a824b1 commit 3bc9214

File tree

5 files changed

+13
-15
lines changed

5 files changed

+13
-15
lines changed

lib/node_modules/@stdlib/math/base/special/factorial2/README.md

+2-2
Original file line numberDiff line numberDiff line change
@@ -130,10 +130,10 @@ double out = stdlib_base_factorial2( 3 );
130130

131131
The 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>

lib/node_modules/@stdlib/math/base/special/factorial2/include/stdlib/math/base/special/factorial2.h

+1-1
Original file line numberDiff line numberDiff 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
}

lib/node_modules/@stdlib/math/base/special/factorial2/lib/main.js

+2-6
Original file line numberDiff line numberDiff line change
@@ -24,11 +24,7 @@ var isnan = require( '@stdlib/math/base/assert/is-nan' );
2424
var isInteger = require( '@stdlib/math/base/assert/is-integer' );
2525
var isEven = require( '@stdlib/math/base/assert/is-even' );
2626
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
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 ) {

lib/node_modules/@stdlib/math/base/special/factorial2/manifest.json

+6-3
Original file line numberDiff line numberDiff line change
@@ -40,7 +40,8 @@
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
{
@@ -57,7 +58,8 @@
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
{
@@ -74,7 +76,8 @@
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
]

lib/node_modules/@stdlib/math/base/special/factorial2/src/main.c

+2-3
Original file line numberDiff line numberDiff line change
@@ -21,10 +21,9 @@
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 ) ) {

0 commit comments

Comments
 (0)