Is it important to declare a variable as unsigned if you know it should never be negative? Does it help prevent anything other than negative numbers being fed into a function th
As an aside, I seldom use int
or unsigned int
, rather I use either {int16_t
, int32_t
, ... } or {uint16_t
, uint32_t
, ...}. (You have to include stdint.h
to use them though.) I am not sure how my colleagues find it, but I try to convey the size of the variable this way. In some places, I try to be more blatant by doing some thing like: typedef uint32_t Counter32;