Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

What does "type domain" and "real type" mean?

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.

like image 465
nalzok Avatar asked Apr 06 '16 14:04

nalzok


Video Answer


1 Answers

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 , 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

and

There are three complex types, designated as float _Complex , double _Complex, and long 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.