4 ms·
Is it common to default to a signed integer for tracking a timer? I realize being unsigned it would still overflow but at least you'd get twice the time, no?
by xhrpost 1y ago
Is it common to default to a signed integer for tracking a timer? I realize being unsigned it would still overflow but at least you'd get twice the time, no?
- deleted 1y ago[deleted]
- aidenn0 1y agoIf you get to right before you need to be (taking as long as you want), then wait until overflow, then you still have 12h to do the last tiny part if it's unsigned.
- zero_shift 1y agoSome C programmers take the view that unsigneds have too many disadvantages: undefined behaviour for overflows, and weird type promotion rules. So, they try and avoid uints.
- tekne 1y agoUmm, signed integers are UB on overflow; unsigned is always fine.
- zero_shift 1y agoSorry, you are correct. I don't think unsigned overflow behaviour was defined until C99 though. Anyway, in answer to the question, I would guess the reason was because of signed / unsigned type promotion.