Recipe 1.12 Converting Fahrenheit to Celsius

Problem

You have a temperature reading measured in Fahrenheit and need to convert it to Celsius.

Solution

 public static double FtoC(double fahrenheit) {     return ((0.5/0.9) * (fahrenheit - 32)); } 

Discussion

This recipe makes use of the following Fahrenheit-to-Celsius temperature conversion equation:

 TempFahrenheit = ((9 / 5) * TempCelsius) + 32 

The Fahrenheit temperature scale is widely used in the United States. However, much of the rest of the world uses the Celsius temperature scale.



C# Cookbook
C# 3.0 Cookbook
ISBN: 059651610X
EAN: 2147483647
Year: 2003
Pages: 315

flylib.com © 2008-2017.
If you may any questions please contact us: flylib@qtcs.net