Adding the "ul" to the operand make this number unsigned long.
If you do not explicitly specify the type of the operands, all calculations will be made in int type. Int has comtains values from -32768 to 32767
So where would I find a quark like this on my own? That certainly in not in standard C. I got this program from Arduino Cookbook. (2nd). Have checked in Beginning C for
Arduino, not there either. Not on the timer() on Arduino.cc either.
Not to be uppity but I have a BS in Computer Science and a few years of experience. They did not reinvent the wheel when they made C++. C is a sub set of C++ meaning the built C++ on C. So what works for C should work in C++ but not the other way around. C does all the casting so the given computations should have been saved as unsigned long. Back to my original quest. Where would the instructions for this problem be found and what else is different?
"Saved" - yes, but not evaluated. As I said before, If you do not explicitly specify the type of the operands, all calculations will be made in int type. if the result of the calculation does not fit into the int type, you will get an overflow at the calculation stage. And the fact that you then assign this value to a variable of the long type cannot correct the situation.
The fact that you have not encountered this before is probably due to the fact that you worked on systems where the int is 4 bytes or more, so the probability of overflow is less.
Not to be uppity but if you have a BS in computer science and you can't understand as to why you can't store a UL in an int then my advice would be for you to go back to your institution and relearn that part you missed.
Agreed. A lot of us didn't even get/don't have a BS and we have learnt these things. A "badge" doesn't mean much if you don't have the knowledge to back up the "badge".
Knowledge and application of the knowledge is more important than having a degree.