"type domain" 和 "real type" 是什么意思?
What does "type domain" and "real type" mean?
引自 N1570:
6.3.1.8 Usual arithmetic conversions
1 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. For the
specified operands, each operand is converted, without change of
type domain, to a type whose corresponding real type is the common real type. Unless explicitly stated otherwise, the common
real type is also the corresponding real type of the result, whose type domain is the type domain of the operands if they
are the same, and complex otherwise. This pattern is called the usual
arithmetic conversions:
- First, if the corresponding real type of either operand is long double, the other operand is converted, without change of type
domain, to a type whose corresponding real type is long double.
- Otherwise, ......
什么是 "type domain" 和 "real type"?我搜索了文档,但没有找到定义。
6.2.5 N1570 型号说明如下:
Integer and floating types are collectively called arithmetic types. Each arithmetic type belongs to one type domain: the real type domain comprises the real types, the complex type domain comprises the complex
types.
然后进一步:
There are three
real floating types
, designated as
float
,
double
, and
long
double
.
42)
The set of values of the type
float
is a subset of the set of values of the
type
double
; the set of values of the type
double
is a subset of the set of values of the
type
long double
和
There are three
complex types, designated as
float _Complex
,
double _Complex
, and
long double _Complex
.
(请注意,该标准并未提及任何关于复杂整数类型的内容,因此该标准中定义的所有整数类型都属于实数类型域)。
由此可见,定义域是指real numbers ℝ and complex numbers ℂ的数学概念。
基本上你问题的摘录是说,如果你将一个实数与虚数或一个复数相加,结果也是一个复数;并且操作数在操作前被提升到最大操作数的宽度。
引自 N1570:
6.3.1.8 Usual arithmetic conversions
1 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. For the specified operands, each operand is converted, without change of type domain, to a type whose corresponding real type is the common real type. Unless explicitly stated otherwise, the common real type is also the corresponding real type of the result, whose type domain is the type domain of the operands if they are the same, and complex otherwise. This pattern is called the usual arithmetic conversions:
- First, if the corresponding real type of either operand is long double, the other operand is converted, without change of type domain, to a type whose corresponding real type is long double.
- Otherwise, ......
什么是 "type domain" 和 "real type"?我搜索了文档,但没有找到定义。
6.2.5 N1570 型号说明如下:
Integer and floating types are collectively called arithmetic types. Each arithmetic type belongs to one type domain: the real type domain comprises the real types, the complex type domain comprises the complex types.
然后进一步:
There are three real floating types , designated as
float
,double
, andlong double
. 42) The set of values of the typefloat
is a subset of the set of values of the type double ; the set of values of the type double is a subset of the set of values of the type long double
和
There are three complex types, designated as
float _Complex
,double _Complex
, andlong double _Complex
.
(请注意,该标准并未提及任何关于复杂整数类型的内容,因此该标准中定义的所有整数类型都属于实数类型域)。
由此可见,定义域是指real numbers ℝ and complex numbers ℂ的数学概念。
基本上你问题的摘录是说,如果你将一个实数与虚数或一个复数相加,结果也是一个复数;并且操作数在操作前被提升到最大操作数的宽度。