About unsigned types of recommendations

  Try not to use in your program unsigned types, in order to avoid unnecessary complexity, in particular, not only because of the negative unsigned types (such as age) and use it to represent the value does not exist.
  Int like that make use of signed numbers, so that when the type of operation involves mixing (such as with a comparator symbols and unsigned number) of the boundary need not worry about the situation (for example -1 is promoted to a very large positive number).
  Only when using a binary mask bit segment and only use unsigned.
  If the mixing operation has to be signed and unsigned, use casts expressions, so they also are a signed or unsigned, so it is not necessary to select the type of the result by the compiler.

Reproduced in: https: //www.cnblogs.com/FrankTan/archive/2011/01/23/1942640.html

Guess you like

Origin blog.csdn.net/weixin_34159110/article/details/93907218