精度级别意味着公差范围的数据类型
对于具有暗示容差范围的值而不是特定点的数据类型,有哪些现有的术语和艺术?
一个例子:时间值。在 ISO 8601 表示法中,值 1964
包含值 1964-05
、1964-05-02
、1964-05-02T18 ,
1964-05-02T18:27
, 1964-05-02T18:27:43
,1964-05-02T18:27:43.0613
。
也就是说,这些值中的每一个都不是零维点,而是包含一系列更精确值的区间。
该集合中更精确的值应该与不太精确的值进行比较:
1964 < 1964-05-02 → False
1964 > 1964-05-02 → False
1964 = 1964-05-02 → True
对于不太精确的值中包含的值,“大于”和“小于”都应该为 false。间隔不重叠,所以这不是问题。
1964-05-02T18:27:43 < 1964-05-02T18:30:11 → True
1964-05-02T18:27:43 < 1964-05-02 → False
1964-05-02T18:27:43 < 1964-05-04 → True
但这样的类型应该如何实现呢?我在谈论什么样的比较?对这些值进行算术怎么样?
简而言之,我应该寻找哪些现有知识体系来探索这些概念?
What existing terminology and art is there for data types that have values implying ranges of tolerance, not specific points?
An example: time values. In ISO 8601 notation, the value 1964
encompasses the values 1964-05
, 1964-05-02
, 1964-05-02T18
, 1964-05-02T18:27
, 1964-05-02T18:27:43
, 1964-05-02T18:27:43.0613
.
That is, each one of those values is not a zero-dimensional point, but an interval encompassing a range of more-precise values.
The more precise values in that set should compare equal to the less-precise ones:
1964 < 1964-05-02 → False
1964 > 1964-05-02 → False
1964 = 1964-05-02 → True
and ‘greater than’ and ‘less than’ should be both false for values encompassed within a less-precise value. The intervals don't overlap, so that's not a concern.
1964-05-02T18:27:43 < 1964-05-02T18:30:11 → True
1964-05-02T18:27:43 < 1964-05-02 → False
1964-05-02T18:27:43 < 1964-05-04 → True
But how should such types be implemented? What kind of comparison am I talking about? What about arithmetic on such values?
In short, what existing body of knowledge should I be looking to for exploration of these concepts?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
正如您的斜体字设法解决的那样,这称为区间算术。
您对区间值之间的顺序和相等关系特别感兴趣。维基百科文章没有谈论这一点,但我认为它已经被研究过,因为想要处理数字,甚至是模糊的数字,这是一个相当基本的事情。
我想你会说,如果两个区间的范围根本不重叠,则两个区间不相等,并且如果前者的范围位于,则一个区间大于另一个区间完全高于后者。
但是,我认为您无法对“等于”有一个合理的定义;你可能需要几种不同类型的准平等。您可以说两个不不相等的范围相等,但我认为这并没有真正的帮助。这更像是可能相等。然后是一个范围包含另一个范围的想法,在这种情况下,您可能会说较大的值大致等于较小的值。但是,由于大致相等关系不是对称的,因此它不是等价关系,因此它并不能形成一种良好的通用目的平等。
或者也许这整件事只是有效数字概念的一般情况?我认为区间算术只是用于处理具有有效数字的数字的算术。
As your italics managed to work out, this is called interval arithmetic.
You're specifically interested in order and equality relationships between interval values. The wikipedia article doesn't talk about that, but i assume it has been worked on, as it's a fairly basic thing to want to do with numbers, even fuzzy ones.
I would imagine that you would say that two intervals are not equal if their ranges do not overlap at all, and that an interval is greater than another interval if the former's range lies entirely above the latter's.
However, i don't think you can have a sensible definition of equal; you might need several different kinds of quasi-equality. You could say two ranges which are not not equal are equal, but i don't think that really helps. That's more like possibly equal. Then there's your idea of one range containing another, in which case you might say that the larger was roughly equal to the smaller. However, since the roughly equal relationship is not symmetric, it's not an equivalence relation, and so it doesn't make a good kind of general-purpose equality.
Or maybe this whole thing is just a generalised case of the idea of significant figures? I suppose interval arithmetic is just the arithmetic you use to deal with numbers that have significant figures.