• 博客访问： 7377601
• 博文数量： 159
• 博客积分： 10424
• 博客等级： 少将
• 技术积分： 14605
• 用 户 组： 普通用户
• 注册时间： 2010-07-14 12:45

2015年（5）

2014年（1）

2013年（5）

2012年（10）

2011年（116）

2010年（22）

2011-10-01 18:22:24

Usual Arithmetic Conversion: The integer promotions are performed on both operands. Then the following rules are applied to the promoted operands:
If both operands have the same type, then no further conversion is needed.
Otherwise, if both operands have signed integer types or both have unsigned integer types, the operand with the type of lesser integer conversion rank is converted to the type of the operand with greater rank.
Otherwise, if the operand that has unsigned integer type has rank greater or equal to the rank of the type of the other operand, then the operand with signed integer type is converted the type of the operand with unsigned integer type.
Otherwise, if the type of the operand with signed integer type can represent all of the values of the type of the operand with unsigned integer type, then the operand with unsigned integer type is converted to the type of the operand with signed integer type.
Otherwise, both operands are converted to the unsigned integer type corresponding to the type of the operand with signed integer type.

Rainyzzj2011-10-23 11:43:20

GFree_Wind: 这篇文章中的说明可不是我说的，是C标准说的。你记得Primer中大概哪一节说的吗？我去看一下。.....
C++ Primer 4th 5.12

GFree_Wind2011-10-11 11:50:05

pragma: 我觉得需要搞清楚这个Rank是如何定义的。

#include <stdlib.h>
#include <stdio.h>

int main()
{
//    signed short a;
//    unsigned sho.....

GFree_Wind2011-10-11 10:16:04

pragma: 我觉得需要搞清楚这个Rank是如何定义的。

#include <stdlib.h>
#include <stdio.h>

int main()
{
//    signed short a;
//    unsigned sho.....

GFree_Wind2011-10-10 17:16:27

pragma: 我觉得需要搞清楚这个Rank是如何定义的。

#include <stdlib.h>
#include <stdio.h>

int main()
{
//    signed short a;
//    unsigned sho.....

Every integer type has an integer conversion rank deﬁned as follows:
— No two signed integer types shall have the same rank, even if they hav e the same

GFree_Wind2011-10-10 17:13:38