Last active
September 17, 2016 15:05
-
-
Save AngeloStavrow/c858bf4d80f25744518ef90baf378e75 to your computer and use it in GitHub Desktop.
Playing with Swift 3's Units and Measurements to calculate humidex values.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import Foundation | |
// The air temperature in degrees Celsius. | |
var airTemperature = Measurement(value: 29.74, unit: UnitTemperature.celsius) | |
// The dewpoint temperature in degrees Celsius. | |
var dewpoint = Measurement(value: 19.08, unit: UnitTemperature.celsius) | |
// Calculate the humidex value. | |
let humidex = airTemperature.value + 0.5555 * ((6.11 * exp(5417.7530 * ((1/273.16) - (1/dewpoint.converted(to: UnitTemperature.kelvin).value)))) - 10) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment