Temperature Measurement calculations error

I've found the following inconsistency in how the temperature Measurement addition seems to work.

If I add two like temperatures:


let t1 = Measurement(value:25, unit: UnitTemperature.celsius)

let t2 = Measurement(value:10, unit: UnitTemperature.celsius)

print(t1+t2)


I get the expected 35.0 °C. However with unlike temperatures:


let t1 = Measurement(value:25, unit: UnitTemperature.celsius)

let t2 = Measurement(value:10, unit: UnitTemperature.fahrenheit)

print(t1+t2)


I get 559.07777777778 K or 285.92777777778 °C.


I realize that adding temperatures is problematic, but these results are not consistent.

Replies

value:10, unit: UnitTemperature.fahrenheit

is about -12 °C


Hence :


25°C + 10°F = 25°C - 12°C = 13°C = 286°K


Which explains the figure you get ; but the mix of unit is totally confusing the compiler.


Check in doc if you are authorized to do such a mix

Question: how do you get : get 559.07777777778 K or 285.92777777778 °C.

Eventually, file a bug report.