arithmatic returns max value

edit removed first question since 2 cups of coffee has enlightened me this morning. an hour of sleep was not enough.

also as an aside, is there a clear inglish table showing the "precedence" or heirachy of different variable types in arithmetic? my understanding is on the right side of the equation all the values are temp promoted to the "highest" variable type, then cast back ot hte proper left hand side variable type. seems that in arduinoland this is

float long int byte

however no referece as to where unsigned versions of values land in this heirachy was made clear to me in my search, just a lot of vague and occasionally contradictory forum posts, and a few references to a standard. when I looked up the standard I either only kept finidng a synopsis of it, or really really didn't understand the hybrid code/layweresse language it was written in.

I just wrote a small sketch using unsigned longs that divided 10 by 100 and got 0. Not sure why yours is different.

You can find an operator precedence table at:

http://www.difranco.net/compsci/C_Operator_Precedence_Table.htm

There are two types of casts in C: 1) Silent casts, which are done "behind your back" automatically by the compiler, and 2) explicit casts where you specify the conversion. Using Purdum's Bucket Analogy, if you have a larger data type on the right side of the assignment operator (e.g., a 4 byte long) and are trying to assign it into a byte on the left side of the assignment operator, you're trying to pour the data from a 4-byte bucket into a 1-byte bucket, so you run the risk of losing information in the process. This situation demands an explicit cast.

If the reverse is true (i.e., a byte on the right side of the assignment operator and a long on the left side), you're trying to pour 1 byte of information into a 4-byte bucket. Since this does not have the potential of losing information, a silent cast is done automatically, and the byte data is made to "fit into" the larger data type. No explicit cast is needed in this situation; the compiler takes care of it for you.