Strange conversion results


I’ve been following this chapter closely, and I seem to be getting some wild results when I run WorldTrotter on the simulator. I’m a little stumped as to why I’m getting these odd conversion results. I’ve gone through from scratch twice, and I keep getting the same error. Everything works fine up until I create the function updateCelsiusLabel() and update fahrenheitFieldEditingChanged() on pg. 80

If anyone could point me in the right direction I’d be very grateful!


What exactly is the problem? That conversion looks right.

import Foundation

struct TemperatureConversion {
    static var fahrenheitValue = Measurement <UnitTemperature> (value: 40, unit: .fahrenheit)
    static var celsiusValue    = Measurement <UnitTemperature> (value: 4.44444444444673, unit: .celsius)

    static func main () {
        print ("\(fahrenheitValue) -> \(fahrenheitValue.converted (to:.celsius))")
        print ("\(celsiusValue) -> \(celsiusValue.converted (to:.fahrenheit))")

40.0 °F  -> 4.44444444444673 °C
4.44444444444673 °C -> 40.0 °F

You are right!

The level of precision showed a result that went beyond the limits of the screen, which looked as if I was getting incorrect output.

Thanks for pointing me in the right direction.