Skip to content
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -130,10 +130,10 @@ double out = stdlib_base_factorial2( 3 );

The function accepts the following arguments:

- **x**: `[in] int32_t` input value.
- **n**: `[in] int32_t` input value.

```c
double stdlib_base_factorial2( const int32_t x );
double stdlib_base_factorial2( const int32_t n );
```

</section>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ extern "C" {
/**
* Evaluates the double factorial of `n`.
*/
double stdlib_base_factorial2( const int32_t x );
double stdlib_base_factorial2( const int32_t n );

#ifdef __cplusplus
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -24,11 +24,7 @@ var isnan = require( '@stdlib/math/base/assert/is-nan' );
var isInteger = require( '@stdlib/math/base/assert/is-integer' );
var isEven = require( '@stdlib/math/base/assert/is-even' );
var PINF = require( '@stdlib/constants/float64/pinf' );


// VARIABLES //

var MAX_FACTORIAL2 = 301; // TODO: consider extracting as a constant
var FLOAT64_MAX_SAFE_NTH_DOUBLE_FACTORIAL = require( '@stdlib/constants/float64/max-safe-nth-double-factorial' ); // eslint-disable-line id-length


// MAIN //
Expand Down Expand Up @@ -63,7 +59,7 @@ function factorial2( n ) {
if ( isnan( n ) ) {
return NaN;
}
if ( n >= MAX_FACTORIAL2 ) {
if ( n >= FLOAT64_MAX_SAFE_NTH_DOUBLE_FACTORIAL ) {
return PINF;
}
if ( n < 0 || isInteger( n ) === false ) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,8 @@
"@stdlib/math/base/assert/is-nan",
"@stdlib/math/base/assert/is-integer",
"@stdlib/math/base/assert/is-even",
"@stdlib/constants/float64/pinf"
"@stdlib/constants/float64/pinf",
"@stdlib/constants/float64/max-safe-nth-double-factorial"
]
},
{
Expand All @@ -57,7 +58,8 @@
"@stdlib/math/base/assert/is-nan",
"@stdlib/math/base/assert/is-integer",
"@stdlib/math/base/assert/is-even",
"@stdlib/constants/float64/pinf"
"@stdlib/constants/float64/pinf",
"@stdlib/constants/float64/max-safe-nth-double-factorial"
]
},
{
Expand All @@ -74,7 +76,8 @@
"@stdlib/math/base/assert/is-nan",
"@stdlib/math/base/assert/is-integer",
"@stdlib/math/base/assert/is-even",
"@stdlib/constants/float64/pinf"
"@stdlib/constants/float64/pinf",
"@stdlib/constants/float64/max-safe-nth-double-factorial"
]
}
]
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -21,10 +21,9 @@
#include "stdlib/math/base/assert/is_integer.h"
#include "stdlib/math/base/assert/is_even.h"
#include "stdlib/constants/float64/pinf.h"
#include "stdlib/constants/float64/max_safe_nth_double_factorial.h"
#include <stdint.h>

#define MAX_FACTORIAL2 301

/**
* Evaluates the double factorial of `n`.
*
Expand All @@ -43,7 +42,7 @@ double stdlib_base_factorial2( const int32_t n ) {
if ( stdlib_base_is_nan( n ) ) {
return 0.0/0.0; // NaN
}
if ( n >= MAX_FACTORIAL2 ) {
if ( n >= STDLIB_CONSTANT_FLOAT64_MAX_SAFE_NTH_DOUBLE_FACTORIAL ) {
return STDLIB_CONSTANT_FLOAT64_PINF;
}
if ( n < 0 || !stdlib_base_is_integer( n ) ) {
Expand Down