View Single Post
Old 02-19-15, 11:36 AM   #42
buffalobillpatrick
Master EcoRenovator
 
Join Date: Mar 2014
Location: Florissant, Colorado
Posts: 599
Thanks: 814
Thanked 59 Times in 55 Posts
Default

Thanks A/C

float degF=-40.3085122205+(1.81496452942*psi)+(-0.0101201804003*psi^2)+(3.05234258195e-005*psi^3)+(-3.37963005786e-008*psi^4);

Nope, don't compile:

sketch_subcool_3.ino: In function 'float calc_R290_Saturated_Temp(float)':
sketch_subcool_3:214: error: invalid operands of types 'double' and 'int' to binary 'operator^'
sketch_subcool_3:215: error: invalid operands of types 'double' and 'int' to binary 'operator^'
sketch_subcool_3:215: error: invalid operands of types 'double' and 'int' to binary 'operator^'


Code:
float calc_R290_Saturated_Temp(float psi)
{ 

double a = -4.03085122205E+001;
double b = 1.81496452942E+000;
double c = -1.01201804003E-002;
double d = 3.05234258195E-005;
double e = -3.37963005786E-008;

 return (a + (b * psi) + (c * psi*psi) + (d * psi*psi*psi)
           + (e * psi*psi*psi*psi));
       
}  // end calc_R290_Saturated_Temp
BTW, Arduino don't do double floats, it just pretends to, when double is specified in source code the compiler handles them same as single precision float, by actually doing integer add operations..

The above code generates exactly same object code as when data type float is used.

Last edited by buffalobillpatrick; 02-19-15 at 12:09 PM..
buffalobillpatrick is offline   Reply With Quote