I have a very simple function to convert temperature from ˚C TO ˚K.
func convertKelvinToCelsius(temp:Double) ->Double {
return temp - 273.15
}
>
This is expected behavior for floating point values. They cannot be 100% accurately represented.
You can use the XCTAssertEqualWithAccuracy
function to assert floating point values are within a given range of each other.
The reason println
prints the same value for all is because it internally rounds them to two decimals (I assume).