码迷,mamicode.com
首页 > 其他好文 > 详细

Expert C programming书摘

时间:2015-02-16 11:33:27      阅读:108      评论:0      收藏:0      [点我收藏+]

标签:

 

==================  Advice on signed types  ================ 

Avoid unnecessary complexity by minimizing your use of unsigned types.Specifically, dong‘t use an unsigned type to represent a quantity just because it will never be negative (e.g., "age" or "national_debt").

Use a signed type like int and you won‘t have to worry about boundary cases in the detailed rules for promoting mixed types.

Only use unsigned types for bit fields or binary  masks. 

Use casts in expressions, to make all the operands signed or unsigned, so the compiler does not have to choose the result type.

Expert C programming书摘

标签:

原文地址:http://www.cnblogs.com/likeatree/p/4293734.html

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!