Quoted from 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, ......
What is "type domain" and "real type"? I've search the document, but no definition is found.
6.2.5 Types of N1570 says the following:
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.
Then further:
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
and
There are three complex types, designated as
float _Complex
,double _Complex
, andlong double _Complex
.
(do note that the standard does not say anything about complex integer types, so all integer types defined in the standard belong to the real type domain).
Thus it is clear that the domain refers to the mathematical concepts of real numbers ℝ and complex numbers ℂ.
Basically what the excerpt in your question says is that if you for example add a real number with imaginary number or a complex number, the result is also a complex number; and also that the operands are promoted to the width of the largest operand before the operation.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With