diff --git a/CHANGELOG.md b/CHANGELOG.md index 848a251..2d07368 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -4,7 +4,7 @@
-## Unreleased (2024-12-01) +## Unreleased (2024-12-03)
@@ -188,6 +188,28 @@ This release closes the following issue: +
+ +#### [@stdlib/constants/float64/max-safe-nth-tribonacci](https://github.com/stdlib-js/stdlib/tree/develop/lib/node_modules/%40stdlib/constants/float64/max-safe-nth-tribonacci) + +
+ +
+ +##### Features + +- [`27e0f3c`](https://github.com/stdlib-js/stdlib/commit/27e0f3c432b142bcef3e679670802947b9ad16ca) - add `constants/float64/max-safe-nth-tribonacci` [(#3317)](https://github.com/stdlib-js/stdlib/pull/3317) + +
+ + + +
+ +
+ + +
@@ -208,9 +230,10 @@ A total of 3 issues were closed in this release: ### Contributors -A total of 4 people contributed to this release. Thank you to the following contributors: +A total of 5 people contributed to this release. Thank you to the following contributors: - Aayush Khanna +- Athan Reines - Gunj Joshi - Gururaj Gurram - Philipp Burckhardt @@ -225,6 +248,7 @@ A total of 4 people contributed to this release. Thank you to the following cont
+- [`27e0f3c`](https://github.com/stdlib-js/stdlib/commit/27e0f3c432b142bcef3e679670802947b9ad16ca) - **feat:** add `constants/float64/max-safe-nth-tribonacci` [(#3317)](https://github.com/stdlib-js/stdlib/pull/3317) _(by Gunj Joshi, Athan Reines)_ - [`92c0d4e`](https://github.com/stdlib-js/stdlib/commit/92c0d4e65a8ffef2a2264ba906cfe8020c483b13) - **docs:** clean-up and use C floats when appropriate _(by Philipp Burckhardt)_ - [`19343f5`](https://github.com/stdlib-js/stdlib/commit/19343f5f7a3359b989d091ed31d9e3c64cf89c9c) - **chore:** fix copyright years and disable lint rules _(by Philipp Burckhardt)_ - [`31c168c`](https://github.com/stdlib-js/stdlib/commit/31c168c72351f2885bcf7361b9168cefb454f6dc) - **fix:** add missing `f` suffix in `constants/float32/ln-two` [(#3110)](https://github.com/stdlib-js/stdlib/pull/3110) _(by Gunj Joshi)_ diff --git a/float64/max-safe-nth-tribonacci/README.md b/float64/max-safe-nth-tribonacci/README.md new file mode 100644 index 0000000..22751c1 --- /dev/null +++ b/float64/max-safe-nth-tribonacci/README.md @@ -0,0 +1,183 @@ + + +# FLOAT64_MAX_SAFE_NTH_TRIBONACCI + +> Maximum safe nth [Tribonacci number][tribonacci-number] when stored in [double-precision floating-point][ieee754] format. + +
+ +## Usage + + + +```javascript +var FLOAT64_MAX_SAFE_NTH_TRIBONACCI = require( '@stdlib/constants/float64/max-safe-nth-tribonacci' ); +``` + +#### FLOAT64_MAX_SAFE_NTH_TRIBONACCI + +Maximum [safe][safe-integers] nth [Tribonacci number][tribonacci-number] when stored in [double-precision floating-point][ieee754] format. + + + +```javascript +var bool = ( FLOAT64_MAX_SAFE_NTH_TRIBONACCI === 63 ); +// returns true +``` + +
+ + + +
+ +## Examples + + + + + +```javascript +var FLOAT64_MAX_SAFE_NTH_TRIBONACCI = require( '@stdlib/constants/float64/max-safe-nth-tribonacci' ); + +function tribonacci( n ) { + var a; + var b; + var c; + var d; + var i; + + a = 0; + b = 0; + c = 1; + if ( n === 0 ) { + return a; + } + if ( n === 1 ) { + return b; + } + if ( n === 2 ) { + return c; + } + for ( i = 3; i <= n; i++ ) { + d = a + b + c; + a = b; + b = c; + c = d; + } + return c; +} + +var v; +var i; +for ( i = 0; i < 100; i++ ) { + v = tribonacci( i ); + if ( i > FLOAT64_MAX_SAFE_NTH_TRIBONACCI ) { + console.log( 'Unsafe: %d', v ); + } else { + console.log( 'Safe: %d', v ); + } +} +``` + +
+ + + + + +* * * + +
+ +## C APIs + + + +
+ +
+ + + + + +
+ +### Usage + +```c +#include "stdlib/constants/float64/max_safe_nth_tribonacci.h" +``` + +#### STDLIB_CONSTANT_FLOAT64_MAX_SAFE_NTH_TRIBONACCI + +Maximum [safe][safe-integers] nth [Tribonacci number][tribonacci-number] when stored in [double-precision floating-point][ieee754] format. + +
+ + + + + +
+ +
+ + + + + +
+ +
+ + + +
+ + + + + + + + + + + + + + diff --git a/float64/max-safe-nth-tribonacci/docs/repl.txt b/float64/max-safe-nth-tribonacci/docs/repl.txt new file mode 100644 index 0000000..8228c97 --- /dev/null +++ b/float64/max-safe-nth-tribonacci/docs/repl.txt @@ -0,0 +1,13 @@ + +{{alias}} + Maximum safe nth Tribonacci number when stored in double-precision + floating-point format. + + Examples + -------- + > {{alias}} + 63 + + See Also + -------- + diff --git a/float64/max-safe-nth-tribonacci/docs/types/index.d.ts b/float64/max-safe-nth-tribonacci/docs/types/index.d.ts new file mode 100644 index 0000000..bf85fb6 --- /dev/null +++ b/float64/max-safe-nth-tribonacci/docs/types/index.d.ts @@ -0,0 +1,33 @@ +/* +* @license Apache-2.0 +* +* Copyright (c) 2024 The Stdlib Authors. +* +* Licensed under the Apache License, Version 2.0 (the "License"); +* you may not use this file except in compliance with the License. +* You may obtain a copy of the License at +* +* http://www.apache.org/licenses/LICENSE-2.0 +* +* Unless required by applicable law or agreed to in writing, software +* distributed under the License is distributed on an "AS IS" BASIS, +* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +* See the License for the specific language governing permissions and +* limitations under the License. +*/ + +// TypeScript Version: 4.1 + +/** +* Maximum safe nth Tribonacci number when stored in double-precision floating-point format. +* +* @example +* var max = FLOAT64_MAX_SAFE_NTH_TRIBONACCI; +* // returns 63 +*/ +declare const FLOAT64_MAX_SAFE_NTH_TRIBONACCI: number; + + +// EXPORTS // + +export = FLOAT64_MAX_SAFE_NTH_TRIBONACCI; diff --git a/float64/max-safe-nth-tribonacci/docs/types/test.ts b/float64/max-safe-nth-tribonacci/docs/types/test.ts new file mode 100644 index 0000000..fd1e495 --- /dev/null +++ b/float64/max-safe-nth-tribonacci/docs/types/test.ts @@ -0,0 +1,28 @@ +/* +* @license Apache-2.0 +* +* Copyright (c) 2024 The Stdlib Authors. +* +* Licensed under the Apache License, Version 2.0 (the "License"); +* you may not use this file except in compliance with the License. +* You may obtain a copy of the License at +* +* http://www.apache.org/licenses/LICENSE-2.0 +* +* Unless required by applicable law or agreed to in writing, software +* distributed under the License is distributed on an "AS IS" BASIS, +* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +* See the License for the specific language governing permissions and +* limitations under the License. +*/ + +import FLOAT64_MAX_SAFE_NTH_TRIBONACCI = require( './index' ); + + +// TESTS // + +// The export is a number... +{ + // eslint-disable-next-line @typescript-eslint/no-unused-expressions + FLOAT64_MAX_SAFE_NTH_TRIBONACCI; // $ExpectType number +} diff --git a/float64/max-safe-nth-tribonacci/examples/index.js b/float64/max-safe-nth-tribonacci/examples/index.js new file mode 100644 index 0000000..dcd5b4a --- /dev/null +++ b/float64/max-safe-nth-tribonacci/examples/index.js @@ -0,0 +1,60 @@ +/** +* @license Apache-2.0 +* +* Copyright (c) 2024 The Stdlib Authors. +* +* Licensed under the Apache License, Version 2.0 (the "License"); +* you may not use this file except in compliance with the License. +* You may obtain a copy of the License at +* +* http://www.apache.org/licenses/LICENSE-2.0 +* +* Unless required by applicable law or agreed to in writing, software +* distributed under the License is distributed on an "AS IS" BASIS, +* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +* See the License for the specific language governing permissions and +* limitations under the License. +*/ + +'use strict'; + +var FLOAT64_MAX_SAFE_NTH_TRIBONACCI = require( './../lib' ); // eslint-disable-line id-length + +function tribonacci( n ) { + var a; + var b; + var c; + var d; + var i; + + a = 0; + b = 0; + c = 1; + if ( n === 0 ) { + return a; + } + if ( n === 1 ) { + return b; + } + if ( n === 2 ) { + return c; + } + for ( i = 3; i <= n; i++ ) { + d = a + b + c; + a = b; + b = c; + c = d; + } + return c; +} + +var v; +var i; +for ( i = 0; i < 100; i++ ) { + v = tribonacci( i ); + if ( i > FLOAT64_MAX_SAFE_NTH_TRIBONACCI ) { + console.log( 'Unsafe: %d', v ); + } else { + console.log( 'Safe: %d', v ); + } +} diff --git a/float64/max-safe-nth-tribonacci/include/stdlib/constants/float64/max_safe_nth_tribonacci.h b/float64/max-safe-nth-tribonacci/include/stdlib/constants/float64/max_safe_nth_tribonacci.h new file mode 100644 index 0000000..1c3c96f --- /dev/null +++ b/float64/max-safe-nth-tribonacci/include/stdlib/constants/float64/max_safe_nth_tribonacci.h @@ -0,0 +1,27 @@ +/** +* @license Apache-2.0 +* +* Copyright (c) 2024 The Stdlib Authors. +* +* Licensed under the Apache License, Version 2.0 (the "License"); +* you may not use this file except in compliance with the License. +* You may obtain a copy of the License at +* +* http://www.apache.org/licenses/LICENSE-2.0 +* +* Unless required by applicable law or agreed to in writing, software +* distributed under the License is distributed on an "AS IS" BASIS, +* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +* See the License for the specific language governing permissions and +* limitations under the License. +*/ + +#ifndef STDLIB_CONSTANTS_FLOAT64_MAX_SAFE_NTH_TRIBONACCI_H +#define STDLIB_CONSTANTS_FLOAT64_MAX_SAFE_NTH_TRIBONACCI_H + +/** +* Maximum safe nth Tribonacci number when stored in single-precision floating-point format. +*/ +#define STDLIB_CONSTANT_FLOAT64_MAX_SAFE_NTH_TRIBONACCI 63 + +#endif // !STDLIB_CONSTANTS_FLOAT64_MAX_SAFE_NTH_TRIBONACCI_H diff --git a/float64/max-safe-nth-tribonacci/lib/index.js b/float64/max-safe-nth-tribonacci/lib/index.js new file mode 100644 index 0000000..a5d25ca --- /dev/null +++ b/float64/max-safe-nth-tribonacci/lib/index.js @@ -0,0 +1,49 @@ +/** +* @license Apache-2.0 +* +* Copyright (c) 2024 The Stdlib Authors. +* +* Licensed under the Apache License, Version 2.0 (the "License"); +* you may not use this file except in compliance with the License. +* You may obtain a copy of the License at +* +* http://www.apache.org/licenses/LICENSE-2.0 +* +* Unless required by applicable law or agreed to in writing, software +* distributed under the License is distributed on an "AS IS" BASIS, +* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +* See the License for the specific language governing permissions and +* limitations under the License. +*/ + +'use strict'; + +/** +* Maximum safe nth Tribonacci number when stored in double-precision floating-point format. +* +* @module @stdlib/constants/float64/max-safe-nth-tribonacci +* @type {integer} +* +* @example +* var FLOAT64_MAX_SAFE_NTH_TRIBONACCI = require( '@stdlib/constants/float64/max-safe-nth-tribonacci' ); +* // returns 63 +*/ + + +// MAIN // + +/** +* Maximum safe nth Tribonacci number when stored in double-precision floating-point format. +* +* @constant +* @type {integer} +* @default 63 +* @see [Tribonacci number]{@link https://en.wikipedia.org/wiki/Tribonacci_number} +* @see [IEEE 754]{@link https://en.wikipedia.org/wiki/IEEE_754-1985} +*/ +var FLOAT64_MAX_SAFE_NTH_TRIBONACCI = 63|0; // eslint-disable-line id-length + + +// EXPORTS // + +module.exports = FLOAT64_MAX_SAFE_NTH_TRIBONACCI; diff --git a/float64/max-safe-nth-tribonacci/manifest.json b/float64/max-safe-nth-tribonacci/manifest.json new file mode 100644 index 0000000..844d692 --- /dev/null +++ b/float64/max-safe-nth-tribonacci/manifest.json @@ -0,0 +1,36 @@ +{ + "options": {}, + "fields": [ + { + "field": "src", + "resolve": true, + "relative": true + }, + { + "field": "include", + "resolve": true, + "relative": true + }, + { + "field": "libraries", + "resolve": false, + "relative": false + }, + { + "field": "libpath", + "resolve": true, + "relative": false + } + ], + "confs": [ + { + "src": [], + "include": [ + "./include" + ], + "libraries": [], + "libpath": [], + "dependencies": [] + } + ] +} diff --git a/float64/max-safe-nth-tribonacci/package.json b/float64/max-safe-nth-tribonacci/package.json new file mode 100644 index 0000000..f849b09 --- /dev/null +++ b/float64/max-safe-nth-tribonacci/package.json @@ -0,0 +1,73 @@ +{ + "name": "@stdlib/constants/float64/max-safe-nth-tribonacci", + "version": "0.0.0", + "description": "Maximum safe nth Tribonacci number when stored in double-precision floating-point format.", + "license": "Apache-2.0", + "author": { + "name": "The Stdlib Authors", + "url": "https://github.com/stdlib-js/stdlib/graphs/contributors" + }, + "contributors": [ + { + "name": "The Stdlib Authors", + "url": "https://github.com/stdlib-js/stdlib/graphs/contributors" + } + ], + "main": "./lib", + "directories": { + "doc": "./docs", + "example": "./examples", + "include": "./include", + "lib": "./lib", + "test": "./test" + }, + "types": "./docs/types", + "scripts": {}, + "homepage": "https://github.com/stdlib-js/stdlib", + "repository": { + "type": "git", + "url": "git://github.com/stdlib-js/stdlib.git" + }, + "bugs": { + "url": "https://github.com/stdlib-js/stdlib/issues" + }, + "dependencies": {}, + "devDependencies": {}, + "engines": { + "node": ">=0.10.0", + "npm": ">2.7.0" + }, + "os": [ + "aix", + "darwin", + "freebsd", + "linux", + "macos", + "openbsd", + "sunos", + "win32", + "windows" + ], + "keywords": [ + "stdlib", + "stdmath", + "constant", + "const", + "max", + "maximum", + "tribonacci", + "number", + "trib", + "safe", + "integer", + "double", + "dbl", + "floating", + "point", + "floating-point", + "float", + "float64", + "f64", + "ieee754" + ] +} diff --git a/float64/max-safe-nth-tribonacci/test/test.js b/float64/max-safe-nth-tribonacci/test/test.js new file mode 100644 index 0000000..b386846 --- /dev/null +++ b/float64/max-safe-nth-tribonacci/test/test.js @@ -0,0 +1,38 @@ +/** +* @license Apache-2.0 +* +* Copyright (c) 2024 The Stdlib Authors. +* +* Licensed under the Apache License, Version 2.0 (the "License"); +* you may not use this file except in compliance with the License. +* You may obtain a copy of the License at +* +* http://www.apache.org/licenses/LICENSE-2.0 +* +* Unless required by applicable law or agreed to in writing, software +* distributed under the License is distributed on an "AS IS" BASIS, +* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +* See the License for the specific language governing permissions and +* limitations under the License. +*/ + +'use strict'; + +// MODULES // + +var tape = require( 'tape' ); +var FLOAT64_MAX_SAFE_NTH_TRIBONACCI = require( './../lib' ); // eslint-disable-line id-length + + +// TESTS // + +tape( 'main export is a number', function test( t ) { + t.ok( true, __filename ); + t.strictEqual( typeof FLOAT64_MAX_SAFE_NTH_TRIBONACCI, 'number', 'main export is a number' ); + t.end(); +}); + +tape( 'the exported value is 63', function test( t ) { + t.strictEqual( FLOAT64_MAX_SAFE_NTH_TRIBONACCI, 63, 'returns expected value' ); + t.end(); +});