I have a small low level function that I use to convert between Celcius and Kelvin. First, is using such a function wasteful (in terms of runtime) given that it essentially just adds 273.15 to the passed value? Next, which of the following implementations is better?
- Code: Select all
inline void C2K(double *T){*T+=273.15;}//Convert Celcius to Kelvin
double SomeFunction(double T,double S){
C2K(&T);//Convert to Kelvins
return exp(2.18867-2275.036/T-1.468591*log(T)+(-0.138681-9.33291/T)*sqrt(S)+0.0726483*S-0.00574938*pow(S,1.5));
}
or
- Code: Select all
inline double C2K(double T){return T+=273.15;}//Convert Celcius to Kelvin
double SomeFunction(double T,double S){
T=C2K(T);//Convert to Kelvins
return exp(2.18867-2275.036/T-1.468591*log(T)+(-0.138681-9.33291/T)*sqrt(S)+0.0726483*S-0.00574938*pow(S,1.5));
}
Thought, comments, et cetera, would be appreciated!
