-
Notifications
You must be signed in to change notification settings - Fork 21
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
Add remaining exact SI constants #336
Merged
Merged
Conversation
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
chiphogg
added
the
release notes: 📏 lib (new units/constants)
PR adding new units or constants to the library
label
Dec 2, 2024
CMake tests are failing; not sure why yet. |
chiphogg
added a commit
that referenced
this pull request
Dec 2, 2024
Turns out, using `IToA` for magnitudes was a little bit sloppy. Magnitude values are always unsigned, which means there are meaningful values that won't fit inside of an `int64_t`. Fortunately, adding all those constants (#336) was a great stress test to expose this. I think the most natural fix would be to add a `UIToA`, which can't handle signed values, but which _can_ handle the "upper half" of `uint64_t` values. This way, we can have `IToA` delegate to `UIToA` for the "integer magnitude" parts of the logic. Why not just get rid of `IToA` altogether? Well, we do need it for printing exponents, which can be negative. Helps #90: this gets the test to pass on #336.
Merged
Autogenerated by bonsai, do not edit |
chiphogg
added a commit
that referenced
this pull request
Dec 2, 2024
Turns out, using `IToA` for magnitudes was a little bit sloppy. Magnitude values are always unsigned, which means there are meaningful values that won't fit inside of an `int64_t`. Fortunately, adding all those constants (#336) was a great stress test to expose this. I think the most natural fix would be to add a `UIToA`, which can't handle signed values, but which _can_ handle the "upper half" of `uint64_t` values. This way, we can have `IToA` delegate to `UIToA` for the "integer magnitude" parts of the logic. Why not just get rid of `IToA` altogether? Well, we do need it for printing exponents, which can be negative. Helps #90: this gets the test to pass on #336.
Answer: we needed #337. All good now. |
All values were taken from [this section] of the wikipedia page on the 2019 revision of the SI. Admittedly, two of them --- `Delta_nu_Cs` and `K_cd` have horribly awkward names. The best I could do for the constant names was `CESIUM_HYPERFINE_TRANSITION_FREQUENCY` and `LUMINOUS_EFFICACY_540_TERAHERTZ`, respectively. That's fine; we expect most users to do something like this in their programs: ```cpp constexpr auto K_cd = au::LUMINOUS_EFFICACY_540_TERAHERTZ; ``` [this section]: https://en.wikipedia.org/wiki/2019_revision_of_the_SI#Defining_constants
chiphogg
force-pushed
the
chiphogg/exact-si-constants#90
branch
from
December 2, 2024 18:46
a53d0c6
to
48795e8
Compare
geoffviola
approved these changes
Dec 2, 2024
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.
Looks good. I did some spot checks against the wikipedia page and it seems to match.
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
All values were taken from this section of the wikipedia page on the
2019 revision of the SI.
Admittedly, two of them ---
Delta_nu_Cs
andK_cd
--- have horriblyawkward names. The best I could do for the constant names was
CESIUM_HYPERFINE_TRANSITION_FREQUENCY
andLUMINOUS_EFFICACY_540_TERAHERTZ
, respectively. That's fine; we expectmost users to do something like this in their programs:
Helps #90.