什么是积分推广及使用C平衡之间的区别?
什么是不可或缺的推广和平衡之间的区别。 (!除了逻辑运算符和放大器;&放;, ||,)我们可以说,任何类型转换为ATLEAST INT或执行任何操作之前无符号整型总结这两个规则,一个更大的类型,如果任何一个操作数是类型比INT更大?
What is the difference between integral promotion and balancing. Can we sum up both the rules by saying that any type is converted to atleast int or unsigned int type before performing any operation(except logical operators &&, ||, !) and to a greater type if any of the operand is of type greater than int ?
有标准两个不同的东西,但没有被称为平衡:
There are two different things in the standard but none is called balancing:
如果一个 INT
可以重新present原始类型的所有值(如限制
由宽度为一个位域),值转换为 INT
;
否则,将其转换为 unsigned int类型
。这些被称为
的整数促销的0.58)所有其他类型的整数不变
促销活动。
If an
int
can represent all values of the original type (as restricted by the width, for a bit-field), the value is converted to anint
; otherwise, it is converted to anunsigned int
. These are called the integer promotions.58) All other types are unchanged by the integer promotions.
...
6.3.1.8通常的算术转换许多运营商意想不到算术类型转换的原因和产量结果类型的操作数
以类似的方式。的目的是确定一个共同的实际的类型
操作数和结果。
6.3.1.8 Usual arithmetic conversions Many operators that expect operands of arithmetic type cause conversions and yield result types in a similar way. The purpose is to determine a common real type for the operands and result.
有被应用到不同类型的前pressions运营总的想法是,在该操作数转换为那里是$ p中$ pcision的损失较少的类型。例如,如果 A
是浮动
和 B
的两倍,为总和 A + b
A
转换为双击
前除。如果类C
是无符号长
它首先被转化为双击
为 C + b
。
The general idea for operators that are applied to expressions of different type, is that the the operands are converted to the type where there is the less loss in precision. E.g if a
is float
and b
is double, for the sum a + b
a
is converted to double
before the addition. Similar if c
is unsigned long
it is first converted to double
for c + b
.