3 ms·
Hm, I wonder what kind of questions that entailed. Because unsigned arithmetic in C seems very intuitive to me. I have a hard time coming up with a question tha
by pingyong 7y ago
Hm, I wonder what kind of questions that entailed. Because unsigned arithmetic in C seems very intuitive to me. I have a hard time coming up with a question that would be hard to answer. Certainly, if we're talking about the C standard, unsigned integers are much more intuitive than signed integers.
Although even if there somehow are hard questions, I'm not sure understanding unsigned arithmetic would have helped whoever wrote that code. Because I think if you asked that person "what does this unsigned type do with -5 C?" the answer would have been pretty obvious.
- pjmlp 7y agoYou might not have any issue dealing with it, but are you sure that everyone on a given team, specially when scaled into off-shoring teams of various skill levels, all will master it? I have been coding since the mid-80's and I wouldn't definitely assert that I know it well, without having a look into ISO C standard and the semantic expectations of the abstract C machine and implementation specific behaviors.
- mantap 7y agoThe problem is that programmers tend to confuse the concept of unsigned integers and non-negative integers. They think that just because a number can never be negative it is OK to use an unsigned integer to represent it. This leads to lots of mixed arithmetic of unsigned and signed types which leads to subtle bugs because neither is a subset of the other.
- DmitryOlshansky 7y agoUsually things like: 1u < -1 But more subtle when you have: a.size() - 1 < len
- slrz 7y agoANSI C heavily mixed up the conversion rules for expressions involving both, signed and unsigned, integer types (value-preserving vs. unsigned-preserving in K&R C). This might have been a factor here, given that most of Gosling's peers back then were probably still more familiar with K&R C and its different set of conversion rules.