From 4a7a0affc884c4374fcdec8111c40d15ae2b15ed Mon Sep 17 00:00:00 2001 From: stdlib-bot Date: Mon, 16 Sep 2024 07:47:50 +0000 Subject: [PATCH] Auto-generated commit --- CHANGELOG.md | 23 +++ float32/max-safe-fibonacci/README.md | 172 ++++++++++++++++++ float32/max-safe-fibonacci/docs/repl.txt | 13 ++ .../max-safe-fibonacci/docs/types/index.d.ts | 33 ++++ float32/max-safe-fibonacci/docs/types/test.ts | 28 +++ float32/max-safe-fibonacci/examples/index.js | 49 +++++ .../constants/float32/max_safe_fibonacci.h | 27 +++ float32/max-safe-fibonacci/lib/index.js | 49 +++++ float32/max-safe-fibonacci/manifest.json | 36 ++++ float32/max-safe-fibonacci/package.json | 72 ++++++++ float32/max-safe-fibonacci/test/test.js | 38 ++++ 11 files changed, 540 insertions(+) create mode 100644 float32/max-safe-fibonacci/README.md create mode 100644 float32/max-safe-fibonacci/docs/repl.txt create mode 100644 float32/max-safe-fibonacci/docs/types/index.d.ts create mode 100644 float32/max-safe-fibonacci/docs/types/test.ts create mode 100644 float32/max-safe-fibonacci/examples/index.js create mode 100644 float32/max-safe-fibonacci/include/stdlib/constants/float32/max_safe_fibonacci.h create mode 100644 float32/max-safe-fibonacci/lib/index.js create mode 100644 float32/max-safe-fibonacci/manifest.json create mode 100644 float32/max-safe-fibonacci/package.json create mode 100644 float32/max-safe-fibonacci/test/test.js diff --git a/CHANGELOG.md b/CHANGELOG.md index bbd3de8a..898cfc99 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -10,6 +10,28 @@ ### Packages +
+ +#### [@stdlib/constants/float32/max-safe-fibonacci](https://github.com/stdlib-js/stdlib/tree/develop/lib/node_modules/%40stdlib/constants/float32/max-safe-fibonacci) + +
+ +
+ +##### Features + +- [`e6b6ffb`](https://github.com/stdlib-js/stdlib/commit/e6b6ffbbc11a52fe64529527ceb6e0afc2df31d1) - add `constants/float32/max-safe-fibonacci` [(#2904)](https://github.com/stdlib-js/stdlib/pull/2904) + +
+ + + +
+ +
+ + +
#### [@stdlib/constants/float32/max-safe-nth-factorial](https://github.com/stdlib-js/stdlib/tree/develop/lib/node_modules/%40stdlib/constants/float32/max-safe-nth-factorial) @@ -109,6 +131,7 @@ A total of 2 people contributed to this release. Thank you to the following cont
+- [`e6b6ffb`](https://github.com/stdlib-js/stdlib/commit/e6b6ffbbc11a52fe64529527ceb6e0afc2df31d1) - **feat:** add `constants/float32/max-safe-fibonacci` [(#2904)](https://github.com/stdlib-js/stdlib/pull/2904) _(by Gunj Joshi)_ - [`51787c8`](https://github.com/stdlib-js/stdlib/commit/51787c84fc5805a0144c2596ad8ac631470458b5) - **feat:** add `constants/float64/num-high-word-significand-bits` [(#2889)](https://github.com/stdlib-js/stdlib/pull/2889) _(by Gunj Joshi, Athan Reines)_ - [`511ae22`](https://github.com/stdlib-js/stdlib/commit/511ae22019022653f58464a98034b1821d979714) - **fix:** update folder name [(#2871)](https://github.com/stdlib-js/stdlib/pull/2871) _(by Gunj Joshi)_ - [`f4acf70`](https://github.com/stdlib-js/stdlib/commit/f4acf70af14b1fa8603858a6d6d0727b6c190e5a) - **feat:** add `constants/float32/max-safe-nth-fibonacci` [(#2836)](https://github.com/stdlib-js/stdlib/pull/2836) _(by Gunj Joshi)_ diff --git a/float32/max-safe-fibonacci/README.md b/float32/max-safe-fibonacci/README.md new file mode 100644 index 00000000..3b2d566a --- /dev/null +++ b/float32/max-safe-fibonacci/README.md @@ -0,0 +1,172 @@ + + +# FLOAT32_MAX_SAFE_FIBONACCI + +> Maximum safe [Fibonacci number][fibonacci-number] when stored in [single-precision floating-point][ieee754] format. + +
+ +## Usage + + + +```javascript +var FLOAT32_MAX_SAFE_FIBONACCI = require( '@stdlib/constants/float32/max-safe-fibonacci' ); +``` + +#### FLOAT32_MAX_SAFE_FIBONACCI + +The maximum [safe][safe-integers] [Fibonacci number][fibonacci-number] when stored in [single-precision floating-point][ieee754] format. + + + +```javascript +var bool = ( FLOAT32_MAX_SAFE_FIBONACCI === 14930352 ); +// returns true +``` + +
+ + + +
+ +## Examples + + + + + +```javascript +var FLOAT32_MAX_SAFE_FIBONACCI = require( '@stdlib/constants/float32/max-safe-fibonacci' ); + +var v; +var i; + +function fibonacci( n ) { + var a; + var b; + var c; + var i; + + a = 1; + b = 1; + for ( i = 3; i <= n; i++ ) { + c = a + b; + a = b; + b = c; + } + return b; +} + +for ( i = 0; i < 50; i++ ) { + v = fibonacci( i ); + if ( v > FLOAT32_MAX_SAFE_FIBONACCI ) { + console.log( 'Unsafe: %d', v ); + } else { + console.log( 'Safe: %d', v ); + } +} +``` + +
+ + + + + +* * * + +
+ +## C APIs + + + +
+ +
+ + + + + +
+ +### Usage + +```c +#include "stdlib/constants/float32/max_safe_fibonacci.h" +``` + +#### STDLIB_CONSTANT_FLOAT32_MAX_SAFE_FIBONACCI + +Macro for the maximum [safe][safe-integers] [Fibonacci number][fibonacci-number] when stored in [single-precision floating-point][ieee754] format. + +
+ + + + + +
+ +
+ + + + + +
+ +
+ + + +
+ + + + + + + + + + + + + + diff --git a/float32/max-safe-fibonacci/docs/repl.txt b/float32/max-safe-fibonacci/docs/repl.txt new file mode 100644 index 00000000..0ad6572b --- /dev/null +++ b/float32/max-safe-fibonacci/docs/repl.txt @@ -0,0 +1,13 @@ + +{{alias}} + Maximum safe Fibonacci number when stored in single-precision floating-point + format. + + Examples + -------- + > {{alias}} + 14930352 + + See Also + -------- + diff --git a/float32/max-safe-fibonacci/docs/types/index.d.ts b/float32/max-safe-fibonacci/docs/types/index.d.ts new file mode 100644 index 00000000..728f27d5 --- /dev/null +++ b/float32/max-safe-fibonacci/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 Fibonacci number when stored in single-precision floating-point format. +* +* @example +* var max = FLOAT32_MAX_SAFE_FIBONACCI; +* // returns 14930352 +*/ +declare const FLOAT32_MAX_SAFE_FIBONACCI: number; + + +// EXPORTS // + +export = FLOAT32_MAX_SAFE_FIBONACCI; diff --git a/float32/max-safe-fibonacci/docs/types/test.ts b/float32/max-safe-fibonacci/docs/types/test.ts new file mode 100644 index 00000000..683133fb --- /dev/null +++ b/float32/max-safe-fibonacci/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 FLOAT32_MAX_SAFE_FIBONACCI = require( './index' ); + + +// TESTS // + +// The export is a number... +{ + // eslint-disable-next-line @typescript-eslint/no-unused-expressions + FLOAT32_MAX_SAFE_FIBONACCI; // $ExpectType number +} diff --git a/float32/max-safe-fibonacci/examples/index.js b/float32/max-safe-fibonacci/examples/index.js new file mode 100644 index 00000000..37da564f --- /dev/null +++ b/float32/max-safe-fibonacci/examples/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'; + +var FLOAT32_MAX_SAFE_FIBONACCI = require( './../lib' ); // eslint-disable-line id-length + +var v; +var i; + +function fibonacci( n ) { + var a; + var b; + var c; + var i; + + a = 1; + b = 1; + for ( i = 3; i <= n; i++ ) { + c = a + b; + a = b; + b = c; + } + return b; +} + +for ( i = 0; i < 50; i++ ) { + v = fibonacci( i ); + if ( v > FLOAT32_MAX_SAFE_FIBONACCI ) { + console.log( 'Unsafe: %d', v ); + } else { + console.log( 'Safe: %d', v ); + } +} diff --git a/float32/max-safe-fibonacci/include/stdlib/constants/float32/max_safe_fibonacci.h b/float32/max-safe-fibonacci/include/stdlib/constants/float32/max_safe_fibonacci.h new file mode 100644 index 00000000..68e9c6ee --- /dev/null +++ b/float32/max-safe-fibonacci/include/stdlib/constants/float32/max_safe_fibonacci.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_FLOAT32_MAX_SAFE_FIBONACCI_H +#define STDLIB_CONSTANTS_FLOAT32_MAX_SAFE_FIBONACCI_H + +/** +* Macro for the maximum safe Fibonacci number when stored in single-precision floating-point format. +*/ +#define STDLIB_CONSTANT_FLOAT32_MAX_SAFE_FIBONACCI 14930352 + +#endif // !STDLIB_CONSTANTS_FLOAT32_MAX_SAFE_FIBONACCI_H diff --git a/float32/max-safe-fibonacci/lib/index.js b/float32/max-safe-fibonacci/lib/index.js new file mode 100644 index 00000000..285d2151 --- /dev/null +++ b/float32/max-safe-fibonacci/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 Fibonacci number when stored in single-precision floating-point format. +* +* @module @stdlib/constants/float32/max-safe-fibonacci +* @type {integer} +* +* @example +* var FLOAT32_MAX_SAFE_FIBONACCI = require( '@stdlib/constants/float32/max-safe-fibonacci' ); +* // returns 14930352 +*/ + + +// MAIN // + +/** +* The maximum safe Fibonacci number when stored in single-precision floating-point format. +* +* @constant +* @type {integer} +* @default 14930352 +* @see [Fibonacci number]{@link https://en.wikipedia.org/wiki/Fibonacci_number} +* @see [IEEE 754]{@link https://en.wikipedia.org/wiki/IEEE_754-1985} +*/ +var FLOAT32_MAX_SAFE_FIBONACCI = 14930352; // eslint-disable-line id-length + + +// EXPORTS // + +module.exports = FLOAT32_MAX_SAFE_FIBONACCI; diff --git a/float32/max-safe-fibonacci/manifest.json b/float32/max-safe-fibonacci/manifest.json new file mode 100644 index 00000000..844d692f --- /dev/null +++ b/float32/max-safe-fibonacci/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/float32/max-safe-fibonacci/package.json b/float32/max-safe-fibonacci/package.json new file mode 100644 index 00000000..c19688ff --- /dev/null +++ b/float32/max-safe-fibonacci/package.json @@ -0,0 +1,72 @@ +{ + "name": "@stdlib/constants/float32/max-safe-fibonacci", + "version": "0.0.0", + "description": "Maximum safe Fibonacci number when stored in single-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", + "fibonacci", + "number", + "fib", + "safe", + "integer", + "float", + "flt", + "floating", + "point", + "floating-point", + "float32", + "f32", + "ieee754" + ] +} diff --git a/float32/max-safe-fibonacci/test/test.js b/float32/max-safe-fibonacci/test/test.js new file mode 100644 index 00000000..81f64978 --- /dev/null +++ b/float32/max-safe-fibonacci/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 FLOAT32_MAX_SAFE_FIBONACCI = require( './../lib' ); // eslint-disable-line id-length + + +// TESTS // + +tape( 'main export is a number', function test( t ) { + t.ok( true, __filename ); + t.strictEqual( typeof FLOAT32_MAX_SAFE_FIBONACCI, 'number', 'main export is a number' ); + t.end(); +}); + +tape( 'the exported value is 14930352', function test( t ) { + t.strictEqual( FLOAT32_MAX_SAFE_FIBONACCI, 14930352, 'returns expected value' ); + t.end(); +});