Recently I heard signed/unsigned comparisons maybe tricky in C. e.g., Signed/unsigned comparisons and also some other questions.
My question is - if we have to compare singed type with unsigned (e.g., including =,>,< operators), what strategies exist to avoid problems that arise from such comparison?
Or we should make sure we always compare only int
with int
and unsigned
with unsigned
?
PS. Also it would be nice to know when such comparisons are dangerous?