Closed wellcaffeinated closed 3 years ago
The problem and challenge with handling Celsius is that you then need two Celsius types, one for temperature differences and one for absolute temperatures, and subtracting two temperatures Celsius must give a Celsius difference. Otherwise you can get nonsense results when you convert to Kelvin.
Ah i see what you mean. And i guess that would also necessitate keeping track of kelvin differences in order to convert between those. Fair enough
Perhaps adding a constant called: C0
or something similar would make sense then
let twenty_c : ucum::Kelvin<f64> = 20.0 * ucum::C0;
assert_eq!( *(twenty_c/ucum:K), 273.15);
it would have to perform an addition which would be a bit odd though…
I think a constant for 0 Celsius seems reasonable. You would be able to add it, but it would be in Kelvin at that point, so that doesn't seem too bad.
You could also create a function that inputs Kelvin and outputs a (unitless) conversion to Celsius for printing.
That is how I would handle it if I wanted to use Celsius and also use units.
I think a constant for 0 Celsius seems reasonable. You would be able to add it, but it would be in Kelvin at that point, so that doesn't seem too bad.
You could also create a function that inputs Kelvin and outputs a (unitless) conversion to Celsius for printing.
That is how I would handle it if I wanted to use Celsius and also use units.
that sounds like an extension trait. no reason that needs to exist in the crate
I realize that the documentation for ucum says:
But easy conversion between Celsius and Kelvin is something I expected to be able to do. Perhaps it doesn’t make sense to implement it in the ucum unit system, but perhaps having an additional unit system would make sense. (maybe it should be called “misc”?).
Here is my pathetic attempt to implement this (which doesn’t compile).