gpt4 book ai didi

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

转载 作者:太空狗 更新时间:2023-10-29 17:24:58 24 4
gpt4 key购买 nike

引自 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/

24 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com