3 ms·
Why not to use unsigned int where no negative numbers should occur? You should write code that won't make those values negative anyway. Except that I think uns
by krollew 14y ago
Why not to use unsigned int where no negative numbers should occur? You should write code that won't make those values negative anyway.
Except that I think unsigned int will cause segmentation fault when signed int would cause program run farther and work inproperly. For example, if you use some int as an index. It should be non negative, but you've made mistake and you calculated -1. If you use signed int it would access some data and work if it and probably you will have big problem with debugging. If you used usigned int -1 is incredibly high number which in 99% cases will cause segmentation fault at the source of problem, so process of debugging would be far faster.
When you use that value for some calculations it's the same. Problably such value would make values "unbelivable" and you start debugging at place where such value occured.