表示变量所有可能值的术语

发布于 2024-07-17 21:31:28 字数 436 浏览 2 评论 0原文

是否有一个术语来表示变量可以采用的所有可能值的集合?

类比:
在数学中,函数的域是定义函数的一组值(函数可以作为参数)。

示例:

  • UInt16 类型的变量可以保存 [0-65536) 范围内的值。
  • 完成状态(由双精度值表示)可以保存 [0-100] 范围内的值。
  • 性别(由枚举表示)可以包含 { Male, Female } 之一。

问:
描述变量可以(根据上下文)假设的所有可能值的术语是什么?

基本上需要一个简短版本的“变量值集”。 我见过术语类型用于描述这样的范围,但类型通常包含其他信息位(例如名称、操作、模块)。

Is there a term to represent a set of all possible values a variable can assume?

Analogy:
In mathematics a domain of a function is a set of values a function is defined on (function can take as an argument).

Examples:

  • A variable of type UInt16 can hold values in range [0-65536).
  • Completion status (represented by a double value) can hold a value in range [0-100].
  • Gender (represented by an Enum) can hold one of { Male, Female }.

Q:
What is a term to describe all possible values a variable can (contextually) assume?

Basically need a short version of "set of values for a variable". I have seen term type being used to describe such a range, but Type often encompasses other bits of information (e.g. a name, operations, module).

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(11

暮倦 2024-07-24 21:31:28
  • 值设定
  • 取值范围
  • value set
  • domain
  • value range
幸福还没到 2024-07-24 21:31:28

我还听说过“价值空间”这个术语。

I've also heard "value space" as a term for this.

神也荒唐 2024-07-24 21:31:28

我将其称为“范围”或“值范围”。

I would just call it the "range", or "range of values".

彼岸花ソ最美的依靠 2024-07-24 21:31:28

域是数学术语。

Domain would be the math term.

朱染 2024-07-24 21:31:28

我不知道具有这种含义的特定于编程的术语,但“域”本身似乎是一个相当不错的术语...

[编辑]阅读对此的评论,我实际上更喜欢“范围”。

I don't know of programming-specific jargon with that meaning, but "domain" itself seems like a pretty good one...

[EDIT] Read the comments to this, and I actually prefer "range".

自演自醉 2024-07-24 21:31:28

我不知道这是否是确切的术语(如果有的话),但我总是将其称为范围,或者在枚举选项的情况下。

I don't know if this is the exact terminology (if it even has one) but I have always referred to it as a range or in the case of enums options.

ˇ宁静的妩媚 2024-07-24 21:31:28

范围是正确的术语,如“此方法将返回...范围内的值”; “该变量的预期范围是:...”等。

Range is the proper term, as in "this method will return values within the range of..."; "The expected range of this variable is:..." etc.

甜味拾荒者 2024-07-24 21:31:28

对于原子类型,类型本身描述了范围(例如,int 的范围为-2,147,483,648 到2,147,483,647)。

任何自定义类型都可能有也可能没有范围,因为自定义类型(例如结构、类、接口)是可以由原子或其他自定义类型组成的复合类型。

不同语言之间类型的定义也会有所不同。

简而言之,您通常只能将范围应用于基于特定语言的原子类型。

For atomic types, the type itself describes the range (e.g. int has a range of -2,147,483,648 to 2,147,483,647).

Anything that is a custom type may or may not have a range because custom types (e.g. struct, class, interface) are composite types that can be made up of atomic or other custom types.

The definition of a type will also vary between different languages.

The long and short of it is generally you will only be able to apply a range to atomic types based on a specific language.

世界和平 2024-07-24 21:31:28

这取决于类型系统。 在某些编程语言中,“字符串”可以保存字符序列,而“无符号整数”只能保存正整数。 在其他语言(如 python)中,变量可以保存任何内容,因为它没有特定的类型。

It depends on the type system. In some programming laguages, a "string" can hold a sequence of characters, and an "unsigned int" can only hold positive whole numbers. In others like python, a variable can hold anything at all because it doesn't have a certain type.

深海不蓝 2024-07-24 21:31:28

我们这里的宽客说它被称为价值集。 他们花了很多钱来创造它们,所以我相信他们!

Our quants here say it is called a value set. They get paid tons of money to create them so I believe them!

昨迟人 2024-07-24 21:31:28

您可能会认为变量包含作为一组数字的成员的元素。

因此, domain 是该集合的可能值的良好描述符。

Range 也经常在类似的上下文中使用。 这里我们谈论函数的范围,即函数可以取的值的集合。 由于变量总是包含某些表达式或计算的结果,因此范围显然也有意义。

两者在适当的背景下都是适当的。

You may think of a variable as containing an element that is a member of a set of numbers.

As such, domain is a good descriptor for the possible values of this set.

Range is also often used in a similar context. Here we talk of the range of a function, as the set of values the function can take on. Since a variable always contains the result of some expression or computation, range clearly makes sense too.

Either is appropriate in the proper context.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文