c - "type domain"和 "real type"是什么意思?

标签 c types language-lawyer c11

引自 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, ......

什么是“类型域”和“真实类型”?我搜索了文档,但没有找到定义。

最佳答案

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 ℝ的数学概念。和 complex numbers ℂ .


基本上,您问题中的摘录是说,例如,如果您将实数与虚数或复数相加,结果也是一个复数;并且操作数在操作之前被提升到最大操作数的宽度。

关于c - "type domain"和 "real type"是什么意思?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/36453786/

相关文章:

c# - 大写对象和小写对象有什么区别?

javascript - 列类型的 Cassandra 代码?

c++ - "inline"关键字与 "inlining"概念

c# Reflection - 查找集合的通用类型

c++ - 标准是否要求流构造函数不访问流缓冲区?

javascript - ES6 中 block 级函数的精确语义是什么?

c - 如何在SDL中绘制圆、弧和 vector 图形?

c - 为什么我必须点击 "Enter"两次?

c - 在C中的数组中强制范围

c - pthread 函数返回 vector ?