Long Equation

Can I put very long equation in the codes? Because I only have humidity and temperature data, I have to manipulate some equations for me to have other data needed for my project. Because when i put that long equation, when i compared it to the values computed by excel, they are a bit different. Thank you

You can. The difference might be due to the fact that the Arduinos use float instead of double. But difficult to say without seeing your code.

I used float in declaring the value and used double in the equation

DEWTEMP0 = (237.3 * ( (log10 (double(RH0 / 100))) + ((7.5 * TEMP0) / (237.3 + TEMP0)))) / (7.5 - ( (log10 (double (RH0 / 100))) + ((7.5 * TEMP0) / (273.3 + TEMP0))));

belle12: I used float in declaring the value and used double in the equation

https://www.arduino.cc/en/Reference/Double

"Double precision floating point number. On the Uno and other ATMEGA based boards, this occupies 4 bytes. That is, the double implementation is exactly the same as the float, with no gain in precision."

i change the float to double but the same result

Hi, Can I suggest you break the LONG equation down to SHORTER equations then combine them to get your final answer.

That way you can do the same in Excel and compare the results for each short equation to find any discrepancies.

Tom... :)

You may find it helpful to break the equation over more than one line. Then you can examine the intermediate values. (Edit: bugger, you beat me to it!)

lastchancename: You may find it helpful to break the equation over more than one line. Then you can examine the intermediate values. (Edit: bugger, you beat me to it!)

Great minds think alike.... :o

Thank you :)

It worked! Thank you

belle12: It worked! Thank you

What worked ?

A lot of those parentheses are not needed. Eliminate them if you want it to be shorter.