-
-
Notifications
You must be signed in to change notification settings - Fork 906
feat: add constants/float32/max-safe-nth-lucas
#3337
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Conversation
Coverage Report
The above coverage report was generated for the changes in this PR. |
I arrived at this value using the following code function lucas(n) {
if (n < 0) return null;
if (n === 0) return 2;
if (n === 1) return 1;
let a = 2;
let b = 1;
let c;
for (let i = 2; i <= n; i++) {
c = a + b;
a = b;
b = c;
}
return b;
}
const MAX_SAFE_FLOAT32 = 16777215; // taken from @stdlib/constants/float32/max-safe-integer
for (let n = 0; n < 100; n++) {
const lucasValue = lucas(n);
if (lucasValue > MAX_SAFE_FLOAT32) {
console.log(`Max safe n: ${n-1}`);
console.log(`Last safe Lucas value: ${lucas(n-1)}`);
console.log(`First unsafe Lucas value: ${lucasValue}`);
break;
}
} which gave the output Max safe n: 34
Last safe Lucas value: 12752043
First unsafe Lucas value: 20633239 |
lib/node_modules/@stdlib/constants/float32/max-safe-nth-lucas/README.md
Outdated
Show resolved
Hide resolved
lib/node_modules/@stdlib/constants/float32/max-safe-nth-lucas/examples/index.js
Outdated
Show resolved
Hide resolved
Signed-off-by: Athan <kgryte@gmail.com>
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM. Thanks, @aayush0325!
PR Commit Message
Please review the above commit message and make any necessary adjustments. |
/** | ||
* Macro for the maximum safe nth Lucas number when stored in single-precision floating-point format. | ||
*/ | ||
#define STDLIB_CONSTANT_FLOAT64_MAX_SAFE_NTH_LUCAS 34 |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
There is a typo here that must be fixed, should i reopen this PR and make a commit to fix this or should i make a new PR here @kgryte, I'm really sorry for this.
Resolves #3336
Description
This pull request:
constants/float32/max-safe-nth-lucas
Related Issues
This pull request:
constants/float32/max-safe-nth-lucas
#3336Questions
No.
Other
No.
Checklist
@stdlib-js/reviewers