-
Notifications
You must be signed in to change notification settings - Fork 78
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: negative constants #510
Comments
BTW, I was not aware of CODATA. Maybe we should add most/all of those constants to the library as well? |
Some constants use uncertainty. We could extend #464 with those use cases. |
A magnitude (whether represented via vector spaces, or some imagined future alternative) is a positive real number. I think it's too hasty to say that negative magnitudes make sense: I'm confident they don't. For example, I expect that magnitude logarithms will be critical for implementing logarithmic units such as decibels, but negative numbers do not have logarithms. In mp-units, a constant is just a unit. Do "negative units" make sense? Am I "-73 neginches" tall? Are we sure we want this? Negative constants exist, and we should support them, but it's not clear to me yet how to do that without overly complicating other abstractions. If we want to support them, it seems not all of the following can be true simultaneously.
I think changing 3 would be a huge mistake. I could see some sense in changing 2 by adding a sign parameter to the unit definition, but I really don't want to rush into allowing negative units without thinking it through carefully. (Note that this caution around negative units also reinforces the desire to avoid changing 3, which would also effectively give us negative units.) Ultimately, a constant is conceptually a quantity, and quantities can be negative if their values are negative. Many times, we can treat that quantity as a unit, but I think negative quantities complicate that idea: is the "unit" the quantity itself, or its (absolute) magnitude? One other advantage to changing 1 would be the opportunity to represent uncertainty, which is worth pondering. In any case... I think the main takeaway is that this seems like a significant challenge case, and one where we really don't want to rush into committing to a solution without considering very carefully. |
The problem is using the unit abstraction for constants. I can't find any provision that a chosen reference quantity, the unit, must be non-negative.
I think that'd be a better reference for P2982R0,
That's in the context of ISO 80000-2:2019 "18 Scalars, vectors and tensors".
It doesn't read like a requirement, but as a fact. |
I am puzzled now, and I don't really know how to proceed here. We could consider add some structural-type like Please let me know if you have some ideas. |
It must be in the definition of quantity (https://jcgm.bipm.org/vim/en/1.1.html):
Which would imply that units are non-negative.
So quantity is defined as a magnitude. |
It's also true that a number can be negative. |
If we can't find a clear answer from the definition as to whether units can be negative, then we should reach out to leading experts in the field to clarify. It's quite possible that they never mentioned it because it never occurred to them that somebody might try defining a negative unit. |
I considered that. I also tried checking if some truths still hold. |
Good point about the vector space. I can't think of anything that wouldn't "work" per se, I just think from a practical perspective it's likely to be full of gotchas and surprises. On the other hand, it probably wouldn't have any effect on people who don't use negative constants. And, it probably would be possible to replace magnitudes with something that is, essentially, "magnitude and a sign bit" (although I think we'd want to come up with a different name). We'll probably want to tread carefully and solicit expert opinion, but who knows --- maybe this could work! |
ISO 80000-1 §A.4 "Constants" references CODATA: https://physics.nist.gov/cuu/Constants/.
It lists fundamental constants, including some negative ones.
Browse to "All values (ascii)", search for
-
, and see some under the column "Value" being highlighted as negative.One such constant is helion g factor, which is rejected for being negative (https://godbolt.org/z/vao9PKv3s):
The text was updated successfully, but these errors were encountered: