Last active
February 3, 2019 03:20
-
-
Save CallumWatkins/e883d59a8909aeadff982217428715d2 to your computer and use it in GitHub Desktop.
Functions to convert between the Kelvin, Celsius and Fahrenheit temperature scales. License: MIT
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
public static class TemperatureConversions | |
{ | |
public static double KelvinToCelsius(double kelvin) | |
{ | |
return kelvin - 273.15; | |
} | |
public static double KelvinToFahrenheit(double kelvin) | |
{ | |
return kelvin * 1.8 - 459.67; | |
} | |
public static double CelsiusToFahrenheit(double celsius) | |
{ | |
return celsius * 1.8 + 32; | |
} | |
public static double CelsiusToKelvin(double celsius) | |
{ | |
return celsius + 273.15; | |
} | |
public static double FahrenheitToCelsius(double fahrenheit) | |
{ | |
return (fahrenheit - 32) / 1.8; | |
} | |
public static double FahrenheitToKelvin(double fahrenheit) | |
{ | |
return (fahrenheit + 459.67) / 1.8; | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment