Add helpers for converting to and from Fahrenheit

This commit is contained in:
DrSmugleaf
2020-09-01 23:33:42 +02:00
parent 9398f90e7c
commit 8afeb4d094

View File

@@ -9,9 +9,31 @@ namespace Content.Shared.Utility
return celsius + PhysicalConstants.ZERO_CELCIUS;
}
public static float CelsiusToFahrenheit(float celsius)
{
return celsius * 9 / 5 + 32;
}
public static float KelvinToCelsius(float kelvin)
{
return kelvin - PhysicalConstants.ZERO_CELCIUS;
}
public static float KelvinToFahrenheit(float kelvin)
{
var celsius = KelvinToCelsius(kelvin);
return CelsiusToFahrenheit(celsius);
}
public static float FahrenheitToCelsius(float fahrenheit)
{
return (fahrenheit - 32) * 5 / 9;
}
public static float FahrenheitToKelvin(float fahrenheit)
{
var celsius = FahrenheitToCelsius(fahrenheit);
return CelsiusToKelvin(celsius);
}
}
}