4.4 类型转换

from http://www.learncpp.com/cpp-tutorial/44-type-conversion-and-casting/

类型隐式转换

类型隐式转换的步骤如下所示:

Long double (highest)
Double
Float
Unsigned long int
Long int
Unsigned int
Int (lowest)

最底层是int而不是short或是char,是因为char和short在求值时会被扩展为int。

隐式转换会出现一些有趣的问题,如5u - 10。也许你会认为结果是-5.但是10为int型,发生隐式转换成unsigned int型,因此最后结果为unsigned int型,2^32 - 5。又如float fValue = 10/4;

posted on 2012-05-17 21:31 钟谢伟 阅读(138) 评论(0)  编辑 收藏 引用

<2012年7月>
24252627282930
1234567
891011121314
15161718192021
22232425262728
2930311234

导航

统计

常用链接

留言簿(1)

随笔档案

IT网站

My Friends

搜索

最新评论

阅读排行榜

评论排行榜