Create a gist now

Instantly share code, notes, and snippets.

Embed
Swift 3 Double Extensions
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
}
}
@micheltlutz

This comment has been minimized.

Show comment
Hide comment
@micheltlutz

micheltlutz Aug 10, 2017

Usage

var temperatura = 16.5
print(temperatura.celsiusToFahrenheit())
print(temperatura.fahrenheitToCelsius())

Owner

micheltlutz commented Aug 10, 2017

Usage

var temperatura = 16.5
print(temperatura.celsiusToFahrenheit())
print(temperatura.fahrenheitToCelsius())

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment