4 ms·
I'm rusty on C, and confused. What should I use instead of signed int?
by timbre 14y ago
I'm rusty on C, and confused. What should I use instead of signed int?
- rcfox 14y agounsigned int :)
- bvdbijl 14y agoand for negative numbers?
- rcfox 14y agoIn that case, you can be pretty certain that you need a signed integer.
- esrauch 14y agoWhat if you only need to store negative integers?
- duaneb 14y agoIsn't that the same situation as only storing signed integers? The arithmetic is just a little different.
- ralph 14y agoNo, you get room for one more negative int. x = x < 0 ? -x : x; is a common buggy abs(), e.g. when printing an integer. One should test if it's negative, perhaps print the '-', and then ensure it's negative for the rest of the per-digit code.