Created
August 10, 2017 14:03
Star
You must be signed in to star a gist
Swift 3 Double Extensions
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
extension Double | |
{ | |
/** | |
* Calc Celcius to Fahrenheit | |
* @return Double value in Fahrenheit | |
*/ | |
func celsiusToFahrenheit() -> Double | |
{ | |
return self * 9 / 5 + 32 | |
} | |
/** | |
* Calc Fahrenheit to Celcius | |
* @return Double value in Celcius | |
*/ | |
func fahrenheitToCelsius() -> Double | |
{ | |
return (self - 32) * 5 / 9 | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Usage
var temperatura = 16.5
print(temperatura.celsiusToFahrenheit())
print(temperatura.fahrenheitToCelsius())