Closed mpusz closed 1 year ago
I bet SG15 has good input on this. Anyways, going by the name alone, what value
returns is less clear than number
. I'd just document that number
returns the numerical quantity value.
+1 for value()
.
I'm cool with value
. Per https://github.com/mpusz/units/issues/434 and https://github.com/mpusz/units/issues/412 I think it needs to be fully explicit when you pack and unpack values in order to be robust against refactorings (and to just be fully clear: f(foo.value())
doesn't mean anything; f(foo.value_in<millimeters>())
does.
Sure, if we decide to rename it, we will change the name of both functions.
The
data
for containers only returns part of the value, as you needsize
to be able to traverse thedata
. Except forstd::string
, which is null-terminated. That's why I'm against #423. A quantity value is already a value, soquantity::value
returning the number/numerical quantity value feels wrong. -- Extract from https://github.com/mpusz/mp-units/issues/477#issuecomment-1660840414.
Not sure why this is even a question. For me (as a physicist) a quantity is specified by a value, a unit and possibly some additional reference system.
number()
just sounds completely off and always makes me wonder if it is an integer.
Sure, a value is represented by a (real or natural) number, but that's one level below.
In other words: mathematics/CS has numbers, physics has values!
I would also be fine with numerical_value()
and numerical_value_in<mm>()
although this seems a bit verbose. Then again these should not be used too much in code.
Is seems we should revise this issue. Today I was going again through the terms in ISO and SI to check for a better alternative of Reference
(issue #486) and I found the following:
quantity value, value of a quantity value
number and reference together expressing magnitude of a quantity
EXAMPLE 1:Length of a given rod: 5.34 m or 534 cm
https://jcgm.bipm.org/vim/en/1.19.html
It seems that according to both ISO and SI, the "value" contains both a number and a unit, but in this feature, we return only a number. So maybe we should revert the previous number()
and number_in()
member functions?
Alternatively, as proposed by @JohelEGP above we could use numerical_value
as the official documentation states:
numerical quantity value, numerical value of a quantity, numerical value
number in the expression of a quantity value, other than any number serving as the reference
ISO/IEC Guide 99:2007 says:
On the other hand, it also specifies a term numerical quantity value
ISO 80000-1:2022 in chapter 6.2 says: