问题描述
请阅读本段(来自C99标准的6.3.1.8节):
操作数比较.
如果两个操作数具有相同的类型,则不需要进一步的转换.
否则,如果两个操作数都具有符号整数类型或都具有无符号整数类型,则将具有较小整数转换等级的类型的操作数转换为具有较高等级的操作数的类型.
否则,如果具有无符号整数类型的操作数的秩大于或等于另一个操作数的类型的秩,则具有符号整数类型的操作数将转换为具有无符号整数类型的操作数的类型.
否则,如果带符号整数类型的操作数的类型可以表示无符号整数类型的操作数的所有值,则将无符号整数类型的操作数转换为带符号整数类型的操作数的类型. br/>
否则,两个操作数都将转换为与带符号整数类型的操作数类型相对应的无符号整数类型. "
我们在本段中看到转换一词.
我的问题是这种转换是在编译时还是运行时完成的吗?
please read this paragraph(from section 6.3.1.8 of the C99 standard):
operand comparision.
If both operands have the same type, then no further conversions are required.
"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 to 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. "
we see the word conversion in this in this paragraph.
my question is this conversion is accomplished at compile time or runtime?
推荐答案
这篇关于C中的操作数转换的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!