Signed and Unsigned Pitfalls

Consider the following code:

the function divide -20 by 10 and return the result , expect to get -2 as a result but it prints:

its a weird pitfall because the function get signed int and we send -20 and unsigned int and we send 10. It looks ok but the divide cannot perform on different types so the unsigned int is converted to int (big number because msb=1) and we get a wrong result

 

Conclusion

Do not perform operations on different types without explicit casting