Temperature Scale Interconversions

This program computes the corresponding temperature equivalents for any given input temperature arguments on the Fahrenheit, Celsius, Kelvin or Rankine scales.

Temperature Value & Scale =     
Temperatures equivalent to 0 F
= -17.7777777778 C = 255.3722222222 K = 459.67 R
Jay Tanner - 2017
Interconversion Formulas Used

The input temperature argument is internally converted into its equivalent on the Kelvin (K) scale and then that value is, in turn, converted into its equivalent on all the other scales and the computed results displayed.

Applying the mathematical definition, absolute zero means the absence of all heat, thus there cannot be any negative temperatures on either of the absolute (K or R) scales.  The program will report temperatures that equate to below absolute zero as an error.


  • Let:

    F = Degrees Fahrenheit
    C = Degrees Celsius
    K = Degrees Kelvin (kelvins) = Degrees C above absolute zero
    R = Degrees Rankine = Degrees F above absolute zero


  • First, the K-scale equivalent of the given temperature is computed according to whichever one of the following formulas apply.




  • Then, the K-scale temperature value equivalents on the other three scales are computed according to the following formulas.




Jay Tanner - 2017

The Common Standard Temperature Scales: Fahrenheit and Celsius

  • F = Fahrenheit scale
    Invented by German-Dutch physicist, Gabriel Daniel Fahrenheit, in 1724.
    Ideal boiling point of water  = 212 F
    Ideal freezing point of water =  32 F
                                  -
                       Difference = 180 F
    
    On this scale, both negative and positive temperatures are possible and range from -459.67 F  upwards.



  • C = Celsius scale
    Invented by Swedish astronomer Anders Celsius in 1742.
    Ideal boiling point of water  = 100 C
    Ideal freezing point of water =   0 C
                                  -
                       Difference = 100 C
    
    On this scale, both negative and positive temperatures are possible and range from -273.15 C  upwards.


The Absolute Temperature Scales: Kelvin and Rankine

The absolute temperature scales are reckoned upwards from the absolute zero point, where absolute zero refers to the theoretical temperature at which molecular energy is at a minimum or, theoretically, the lowest possible temperature in nature, the absence of all measureable heat.  By definition, there are no negative absolute temperatures.
  • K = Kelvin Scale
    The Kelvin scale is named after the British mathematician and physicist, William Thomson Kelvin, who first proposed it in 1848.  A Kelvin temperature value is simply the measure of the temperature, in degrees Celsius, above absolute zero.

    K = C + 273.15

    The K scale is commonly used in advanced scientific computations and referred to as an absolute temperature scale, starting at zero and measured only positively upward, with no negative values defined.
    Ideal boiling point of water  = 373.15 K
    Ideal freezing point of water = 273.15 K
                                  -
                       Difference = 100 C
    

  • R = Rankine Scale
    The Rankine scale was named after the Scottish engineer and physicist, William John MacQuorn Rankine, who first proposed it in 1859.

    Like the K scale, the Rankine (R) scale is also an absolute scale, but it is reckoned in degrees Fahrenheit instead of degrees Celsius.  Thus, a Rankine temperature value is simply the measure of the temperature, in degrees Fahrenheit, above absolute zero.

    R = F + 459.67
    Ideal boiling point of water  = 671.67 R
    Ideal freezing point of water = 491.67 R
                                  -
                       Difference = 180 F
    

  • Absolute Zero Equivalents

    0.00 K = 0.00 R = -273.15 C = -459.67 F



Notes On the Fahrenheit and Celsius Scales

On the Fahrenheit scale, the difference between boiling and freezing is:
(212 - 32) = 180 F

On the Celsius scale, the difference between boiling and freezing is:
(100 - 0) = 100 C

The ratio of the differences between the boiling and freezing points is:
(212 - 32) / (100 - 0) = 180/100 = 18/10 = 9/5

Thus, the ratio of Fahrenheit to Celsius degrees is 9 to 5.  In other words, a difference of 9 degrees on the Fahrenheit scale equates to a difference of exactly 5 degrees on the Celsius scale. This is the source of those ratios, 9/5 and 5/9, we encounter in the interconversion formulas.

In a linear context, one Celsius degree is 9/5 = 1.8 times longer than a Fahrenheit degree.

Based on the difference ratio defined above and 32 degrees being the freezing point of water on the Fahrenheit scale, the general F/C scale interconversion formulas may be given as:

F = C ×(9/5) + 32
and
C = (F - 32)×(5/9)

It is also very interesting to note that the Fahrenheit and Celsius scales are numerically equal at -40 degrees, which leads to the following alternative interconversion formulas between the F and C scales.

F = (C + 40)×(9/5) - 40
and
C = (F + 40)×(5/9) - 40



Below is a source code listing of the PHP function around which the above program was built.
/*
 ============================================================
 Temperature scale interconversion function.

 Author   : Jay Tanner - 2014
 Language : PHP v5.4.7
 License  : This source code is released under the provisions
            of the GNU Affero General Public License, v3.
            http://www.gnu.org/licenses/agpl.html
 ============================================================

 This function converts any given temperature on the F,C,K
 or R scale into the equivalent temperature on any of the
 other scales.

 The scale symbols are:
 F = Fahrenheit
 C = Celsius
 K = Kelvin  = Degrees Celsius above absolute zero.
 R = Rankine = Degrees Fahrenheit above absolute zero.

 The scale symbols are NOT case sensitive.

 The conversion is performed by first converting the
 input temperature value into its equivalent on the K
 scale, then the K scale value is converted into the
 given output scale.

 -------
 EXAMPLE
 To convert -123.45 C into its equivalent on the R scale:

 print Temp_To_Temp("-123.45 C", "R"); // Result = 269.46


 ------
 ERRORS
 FALSE is returned if a scale symbol is not recognized or
 an asterisk (*) is returned if temperature < absolute zero.
 ============================================================
*/

   function Temp_To_Temp ($FromTempStr, $ToScaleStr)
{
// Read input argument value and scales.
   $w = trim($FromTempStr);   if ($w == '') {$w = "0";}
   $T = floatval($w);

   $FromScale = substr($w, -1);
   $ToScale = trim($ToScaleStr);

// Convert T input ($FromScale) into K scale equivalent.
   switch (strtoupper(trim($FromScale)))
  {
   case "F" : $K = (5 * ($T - 32) / 9) + 273.15; break;
   case "C" : $K = $T + 273.15; break;
   case "K" : $K = $T; break;
   case "R" : $K = (5 * ($T - 491.67) / 9) + 273.15; break;
   default  : $K = FALSE; break;
  }

// ERROR if invalid FromScale.
   if ($K === FALSE) {return $K;}

// Return an asterisk (*) if temperature < absolute zero.
   if ($K < 0) {return '*';}

// Convert K value into output ($ToScale) equivalent T.
   switch (strtoupper(trim($ToScale)))
  {
   case "F" : $T = (9 * ($K - 273.15) / 5) + 32; break;
   case "C" : $T = $K - 273.15; break;
   case "K" : $T = $K; break;
   case "R" : $T = (9 * ($K - 273.15) / 5) + 491.67; break;
   default  : $T = FALSE; break;
  }

   return $T;

} // End of Temp_To_Temp(...)
Jay Tanner - 2017