Skip to content

Commit aa94a37

Browse files
authored
refactor: remove hardcoded constant
PR-URL: #2970 Reviewed-by: Athan Reines <[email protected]>
1 parent d0ebce3 commit aa94a37

File tree

1 file changed

+4
-8
lines changed
  • lib/node_modules/@stdlib/math/base/special/falling-factorial/lib

1 file changed

+4
-8
lines changed

lib/node_modules/@stdlib/math/base/special/falling-factorial/lib/main.js

Lines changed: 4 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -41,11 +41,7 @@ var floor = require( '@stdlib/math/base/special/floor' );
4141
var abs = require( '@stdlib/math/base/special/abs' );
4242
var FLOAT64_MAX = require( '@stdlib/constants/float64/max' );
4343
var PINF = require( '@stdlib/constants/float64/pinf' );
44-
45-
46-
// VARIABLES //
47-
48-
var MAX_FACTORIAL = 170; // TODO: consider packaging as constant
44+
var FLOAT64_MAX_SAFE_NTH_FACTORIAL = require( '@stdlib/constants/float64/max-safe-nth-factorial' ); // eslint-disable-line id-length
4945

5046

5147
// FUNCTIONS //
@@ -181,10 +177,10 @@ function fallingFactorial( x, n ) {
181177
}
182178
if ( x < 0.5 ) {
183179
// Computing `1 + x` will throw away digits, so split up calculation...
184-
if ( n > MAX_FACTORIAL-2 ) {
180+
if ( n > FLOAT64_MAX_SAFE_NTH_FACTORIAL-2 ) {
185181
// Given a ratio of two very large numbers, we need to split the calculation up into two blocks:
186-
t1 = x * fallingFactorial( x-1.0, MAX_FACTORIAL-2 );
187-
t2 = fallingFactorial( x-MAX_FACTORIAL+1.0, n-MAX_FACTORIAL+1 );
182+
t1 = x * fallingFactorial( x-1.0, FLOAT64_MAX_SAFE_NTH_FACTORIAL-2 ); // eslint-disable-line max-len
183+
t2 = fallingFactorial( x-FLOAT64_MAX_SAFE_NTH_FACTORIAL+1.0, n-FLOAT64_MAX_SAFE_NTH_FACTORIAL+1 ); // eslint-disable-line max-len
188184
if ( FLOAT64_MAX/abs(t1) < abs(t2) ) {
189185
return PINF;
190186
}

0 commit comments

Comments
 (0)