In my program two variables are declared as signed long (let say X and Y on 32 bit machine) and these divided one by other(X/Y).
The final value is assigned to a unsigned long variable(Let say Z). I am not sure whether this is right or wrong assignment. I am just debugging a code that was written by some one. I guess this may lead to overflow or undefined state.
What happens in below four scenarios,
Z =+X/+Y
Z =+X/-Y
Z =-X/+Y
Z =-X/-Y
I know that %u for unsigned and %d for integer. My question is regarding what value would be stored in Z in the above four scenarios.
Any help would be greatly appreciated.