integer math difficulties

I'm on my first project, it's a light-level triggered camera flash trigger. I am using a TSL230 so I have to deal with frequencies for everything. It's pretty much working the way I want it to, but I have constantly run into math issues. I have a background with programming and signal processing but never at the micro-controller level. I've noticed that the arduino is really sensitive to how an equation is entered. it seems like if part of the equation goes out of the bounds of the result type, the result ends up being overloaded. For example the result type below is an unsigned integer so while the equations are equivalent the first ends up with a bogus result. Is there a resource that explains how arduino processes equations so I can understand exactly what is going on?

def_thresh = avg_f + (min_f-avg_f)*1.1; def_thresh = avg_f - (avg_f-min_f)*1.1;

I think, arduino process equations as it prescribed by C++ . You can get overflow or incorrect results easily with int. math simply not paying attention to rounding float to int.

It's not the Arduino that's doing it, it's standard C++, so check any reference as to data types, implicit conversions, etc. Actually it sounds like you already have a good idea of what's going on!

Thanks for the replies. With C++ on a PC it doesn't really matter how big small some parts of the equation get as long as the result fits into the variable type right? I thought this was related to some overhead limit related to the hardware.

The difference only with PC - size of integer, 32-bit on PC and 16-bit on arduino.
So, yes it easier to get in trouble on arduino, especially if you have some byte / char variable in equation, with only 8-bit size

it seems like if part of the equation goes out of the bounds of the result type, the result ends up being overloaded.

The computations are performed based on the type of variable/value being operated on. Only when the computation is complete is the type of variable to store the result in a factor.

Don't let the result type mislead you in how a result will be computed.