I apologize, but my google-fu is apparently non-existent tonight. And I keep finding conflicting info on order of operations with Arduino.
Can someone explain to me why this:
float percent = ( (transitionTime * 60) - ( ( sunriseTime + (transitionTime * 60) ) - now.unixtime() ) ) / (transitionTime * 60 );
Does not return the same as this:
float percent = (transitionTime * 60) - ( ( sunriseTime + (transitionTime * 60) ) - now.unixtime() );
percent = percent / ( transitionTime * 60 );
Thanks!
system
#2
In the first code, all the values are integers, so integer arithmetic is performed.
In the second code, integer arithmetic is performed, and the result stored in a float. Then, floating point arithmetic is performed.
Ps991
#3
It might be because you need to force it to do floating point math
try this?
... / ( (float) transitionTime * 60 );
or maybe even this
... / ( transitionTime * 60.0 );
Thanks guys. You are right on. I did Ps991 and added the 60.0 on the end.