1. CODE : Temprature Conversion

Carl R. White sent the following functions to the list :

function FtoC(atom farenheit)
    return (farenheit - 32) / 1.8
end function

function CtoF(atom celcius) -- or centigrade if you want
    return celcius * 1.8 + 32
end function

Here are 4 functions to complement these,
K stands for Kelvin (Standard Unit for Temperature) a system that starts at
 absolute zero and uses the same scale as Celcius.

function CtoK(atom celcius)
                return celcius - 273
end function

function FtoK(atom farenheit)
                return ( (farenheit - 32) / 1.8 ) - 273
end function

function KtoC(atom kelvin)
                return kelvin + 273
end function

function KtoF(atom Kelvin)
                return ( celcius + 273) * 1.8 + 32
end function


---
Sincerely,
Mathew Hounsell
Mat.Hounsell at mailexcite.com



Free web-based email, Forever, From anywhere!
http://www.mailexcite.com

new topic     » topic index » view message » categorize

2. Re: CODE : Temprature Conversion

>function KtoF(atom Kelvin)
>                return ( celcius + 273) * 1.8 + 32
>end function

Guess you typed this directly, this one should probably read:

function KtoF(atom kelvin)
    return (kelvin + 273) * 1.8 + 32
end function

Einar Mogen

new topic     » goto parent     » topic index » view message » categorize

3. Re: CODE : Temprature Conversion

Matt Hounsell added to Carl White's temperature routines. For those of you who
care, I have tweaked them a little. 0 celsius is actually 273.15 K.

> function FtoC(atom farenheit)
--Here I replace a divide with a multiply
>      return (farenheit - 32) * .555555
>  end function
>
>  function CtoF(atom celcius) -- or centigrade if you want
>      return celcius * 1.8 + 32
>  end function
>
>  Here are 4 functions to complement these,
>  K stands for Kelvin (Standard Unit for Temperature) a system that starts at
>   absolute zero and uses the same scale as Celcius.
>
>  function CtoK(atom celcius)
--This was previously a - and is now correctly a + (0 Celsius = 273.15 K)
>                  return celcius + 273.15
>  end function
>
>  function FtoK(atom farenheit)
--Ditto here
>                  return ( (farenheit - 32) * .555555 ) + 273.15
>  end function
>
>  function KtoC(atom kelvin)
--Ooops ! They were all wrong ! Sorry Mat
>                  return kelvin - 273.15
>  end function
>
>  function KtoF(atom kelvin)
--Plus Einar's correction here
>                  return ( kelvin - 273.15) * 1.8 + 32
>  end function

"Can you live a moment longer by worrying about it ?"

Daniel

new topic     » goto parent     » topic index » view message » categorize

Search



Quick Links

User menu

Not signed in.

Misc Menu