Skip to content

Commit 4bc5c7e

Browse files
authored
refactor: use external constant in math/base/special/tribonacci
PR-URL: #3324 Reviewed-by: Athan Reines <kgryte@gmail.com>
1 parent 1d10ce5 commit 4bc5c7e

File tree

3 files changed

+12
-11
lines changed

3 files changed

+12
-11
lines changed

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

+2-6
Original file line numberDiff line numberDiff line change
@@ -22,14 +22,10 @@
2222

2323
var isnan = require( '@stdlib/math/base/assert/is-nan' );
2424
var isInteger = require( '@stdlib/math/base/assert/is-integer' );
25+
var FLOAT64_MAX_SAFE_NTH_TRIBONACCI = require( '@stdlib/constants/float64/max-safe-nth-tribonacci' ); // eslint-disable-line id-length
2526
var TRIBONACCI = require( './tribonacci.json' );
2627

2728

28-
// VARIABLES //
29-
30-
var MAX_TRIBONACCI = 63;
31-
32-
3329
// MAIN //
3430

3531
/**
@@ -83,7 +79,7 @@ function tribonacci( n ) {
8379
isnan( n ) ||
8480
isInteger( n ) === false ||
8581
n < 0 ||
86-
n > MAX_TRIBONACCI
82+
n > FLOAT64_MAX_SAFE_NTH_TRIBONACCI
8783
) {
8884
return NaN;
8985
}

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

+8-3
Original file line numberDiff line numberDiff line change
@@ -36,7 +36,8 @@
3636
"libraries": [],
3737
"libpath": [],
3838
"dependencies": [
39-
"@stdlib/math/base/napi/unary"
39+
"@stdlib/math/base/napi/unary",
40+
"@stdlib/constants/float64/max-safe-nth-tribonacci"
4041
]
4142
},
4243
{
@@ -49,7 +50,9 @@
4950
],
5051
"libraries": [],
5152
"libpath": [],
52-
"dependencies": []
53+
"dependencies": [
54+
"@stdlib/constants/float64/max-safe-nth-tribonacci"
55+
]
5356
},
5457
{
5558
"task": "examples",
@@ -61,7 +64,9 @@
6164
],
6265
"libraries": [],
6366
"libpath": [],
64-
"dependencies": []
67+
"dependencies": [
68+
"@stdlib/constants/float64/max-safe-nth-tribonacci"
69+
]
6570
}
6671
]
6772
}

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

+2-2
Original file line numberDiff line numberDiff line change
@@ -17,8 +17,8 @@
1717
*/
1818

1919
#include "stdlib/math/base/special/tribonacci.h"
20+
#include "stdlib/constants/float64/max_safe_nth_tribonacci.h"
2021

21-
static const int32_t STDLIB_CONSTANTS_FLOAT64_MAX_SAFE_NTH_TRIBONACCI = 63; // TODO: consider making a package similar to `@stdlib/constants/float64/max-safe-nth-fibonacci`
2222
static const int64_t tribonacci_value[ 64 ] = {
2323
0,
2424
0,
@@ -96,7 +96,7 @@ static const int64_t tribonacci_value[ 64 ] = {
9696
* // returns 0
9797
*/
9898
double stdlib_base_tribonacci( const int32_t n ) {
99-
if ( n < 0 || n > STDLIB_CONSTANTS_FLOAT64_MAX_SAFE_NTH_TRIBONACCI ) {
99+
if ( n < 0 || n > STDLIB_CONSTANT_FLOAT64_MAX_SAFE_NTH_TRIBONACCI ) {
100100
return 0.0 / 0.0; // NaN
101101
}
102102
return tribonacci_value[ n ];

0 commit comments

Comments
 (0)