I recently came up with a question. Let’s say we have:
void test(int32_t b){
printf("value is %d", b);
}
int main(){
uint32_t a = 43;
test(a);
return 0;
}
What happens when you pass a unsigned variable to a signed parameter? How does the copy of the value work, and how does the cast work?
Can someone explain it to me in detail?
Thanks
If the value is small enough, it is simply assigned. Otherwise it is assigned in an implementation-defined fashion. Typically this means it will “wrap around”.