•I am in a function - passing a pointer to a structure.
•my_param is and unsigned 8-bit int (uint8_t).
The following gives an incorrect result:
#define SECONDS_IN_A_DAY 86400 my_param is and unsigned 8-bit int (uint8_t). uint32_t var = my_strcut->my_param * SECONDS_IN_A_DAY;
If however I cast my_parm the result is correct.
uint32_t var = (uint32_t)my_strcut->my_param * SECONDS_IN_A_DAY;
My understanding of castign was that the first example is a case of implicit casting should still produce the correct result. As the final result of the equation is a 32-bit variable.
Also does the castign have any processor tick/cycle cost?
N.B. I'v made this post not becasue I have a problem with what is going on - more I am interested why.