-
Notifications
You must be signed in to change notification settings - Fork 105
Description
I don't think the "offset" should be part of the unit, but rather the quantity (this is the main beef I have with my favourite units library in python, pint, see my comment here). The main argument is that, as soon as units appear in a compound expression, the offset immediately loses it's meaning (think for example the temperature coefficient of a resistor in kOhm/°C; obviously, that can only refer to temperature differences measured in °C, and there is simply no reasonable meaning to the "offset" of that quantity).
That said, it may make sense to define an implicit "offset" implied by the unit when describing a quantity point (e.g. a thermodynamic temperature) without explicitly specifying a reference point.
I also think we should really consider that information the "point of reference", not an "offset" - that one only appears between related quantities. But then, I have never really worked with quantity equations (and I don't have access to the ISO-80000 standard).
In the end, it would be great if the library would not only work for ISO thermodynamic temperatures, but also custom quantity points. Specifically, while the standard only endorses using °C to specify temperatures with respect to the "Celsisus temperature reference point", C++ programs may have a need to work with "unendorsed" combinations for efficiency reasons. As a specific example, we use this library on an embedded device employing a temperature sensor whose output is an 16 bit integer where zero corresponds to the temperature point -45 °C, and an increment of one corresponds to a temperature change of 0.01 °C. With #232, I can fully embed this information in the quantity_point and work with the original representation. However, I can also do computation with a floating point representation where the point of reference is still - 45 °C, but now I use SI °C for the scaling. Or, I can convert to the standard Celsius temperature reference point and continue to work with 0.01 °C increments, all in integer arithmetic.
Another use-case to consider is the glide-computer example, with different ways to express height/elevation, all using units of m and/or km.
Originally posted by @burnpanck in #391 (comment)