Implicit Type Cast?

Does the arduino support implicit type casting? Say I have an int, and do something like:

int number = 100; byte number2 = number;

will that work out, or would i have to do a:

int number = 100; byte number2 = (byte)number;

i've been a VB programmer for years and i'm just starting to familiarize myself with C. I know c# doesn't allow implicit type casting, but does the arduino?

There's no harm in typing such a thing into a sketch and hitting the Verify button to see for yourself. :)

Yes, for all primitive types, implicit type-casting is performed. In some cases, the compiler may produce a warning if it thinks data may be lost. For example, int x = 1000; byte b = x; would be equivalent to int x = 1000; byte b = (byte)(x % 256); but that may not be obvious in some circumstances.

If you're calling a function or method that has multiple overloads (variations that take different types), the compiler picks the overload that requires the least type-casting. This can be tricky to figure out sometimes, so when in doubt, cast your types yourself.

Lastly, even with an explicit cast, some compilers will complain about the potential incompatibility. I have found that casting twice, first to the actual type, then to the desired type, will usually calm the compiler's fears that I don't know about the issue. This is usually when I have to "work around" a const problem and I can't change a library routine. It's pretty rare. I call this double-casting a "concession," as in, "yes, I know you think it's a long, but I really do want a char out of it."