Open vorburger opened 9 months ago
should be
2°C + 1°C = 276.15°C
Wait, what? Is that a typo, or intentional? It doesn't make sense to me, like this... adding two quantities (2+1) of the same °C unit, becomes a 276.15°C, really?
Yes, that's the whole point of Quantity.Scale.
Check out the Indriya (RI) TemperatureTest or QuantitiesTest by Seshat, another compatible implementation.
As well as TemperatureDemo for
Ask @desruisseaux for the motivation.
Hello @vorburger
adding two quantities (2+1) of the same °C unit, becomes a 276.15°C, really?
Yes, really at least in some cases for the particular case of °C. Actually it depends on whether 1°C is an absolute temperature or an increment. This is why there is a Quantity.Scale
enumeration with two values: ABSOLUTE
and RELATIVE
.
If 1°C is an increment (Scale.RELATIVE
), then 2°C + 1°C is equal to 3°C. But if 1°C is a temperature measurement (Scale.ABSOLUTE
), then the calculation must be done in K. This is required by thermodynamic laws. So 2°C + 1°C is equal to 275.15 K + 274.15 K = 549.30 K = 276.15°C. The reason is that we are computing the amount of energy in a system.
So if you want 2°C + 1°C = 3°C, you need to tell the library that 1°C is an increment rather than an absolute measurement. This ambiguity exists for °C and not for other standard units (ignoring °F) because °C has a zero which is shifted compared to the base SI unit. For non-shifted units, the distinction between absolute and relative makes no difference, because the shift is zero.
A few resources are below. We have to be careful with the answers of this kind of forum as they may sometime be questionable, but the high-ranked answers have good chances to be good resources:
@vorburger Any chance you could fix this PR? As it's just a single digit, we could also close it and address the viable part of it separately.
@keilw
This change is![Reviewable](https://reviewable.io/review_button.svg)