Skip to content
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

feat: add constants/float32/max-safe-nth-fibonacci #2836

Merged
merged 2 commits into from
Aug 29, 2024

Conversation

gunjjoshi
Copy link
Member

Description

What is the purpose of this pull request?

This pull request:

Related Issues

Does this pull request have any related issues?

This pull request:

Questions

Any questions for reviewers of this pull request?

No.

Other

Any other information relevant to this pull request? This may include screenshots, references, and/or implementation notes.

As the max-safe-integer that can be stored in single-precision is 16777215, I chose the maximum possible fibonacci number that can be stored in single-precision to be just below this, which turns out to be 14930352. The next value after that is 24157817 , which is greater than the max-safe-integer.

Also checked it in REPL:

In [11]: float64ToFloat32(24157817)
Out[11]: 24157816

In [12]: float64ToFloat32(14930352)
Out[12]: 14930352

We do not have any precision loss for 14930352, but we do have loss for the next value, i.e., 24157817.

Hence, I chose 36 as the max-safe n.

Checklist

Please ensure the following tasks are completed before submitting this pull request.


@stdlib-js/reviewers

Copy link
Member

@Planeshifter Planeshifter left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM!

@Planeshifter Planeshifter added the Ready To Merge A pull request which is ready to be merged. label Aug 29, 2024
@Planeshifter Planeshifter merged commit f4acf70 into stdlib-js:develop Aug 29, 2024
15 checks passed
@gunjjoshi gunjjoshi deleted the max-safe-fibonacci branch September 6, 2024 18:40
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Ready To Merge A pull request which is ready to be merged.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants