为什么 Haskell 中的无符号整数类型称为“Word”? “ord”代表“序数”吗?
这是关于 Data.Word 的文档:
http://hackage.haskell.org/package/base-4.6.0.1/docs/Data-Word.html#t:Word
这对谷歌来说是一个非常困难的问题!
最佳答案
来自 wikipedia :
The term 'word' is used for a small group of bits which are handled simultaneously by processors of a particular architecture. The size of a word is thus CPU-specific. Many different word sizes have been used, including 6-, 8-, 12-, 16-, 18-, 24-, 32-, 36-, 39-, 48-, 60-, and 64-bit. Since it is architectural, the size of a word is usually set by the first CPU in a family, rather than the characteristics of a later compatible CPU. The meanings of terms derived from word, such as longword, doubleword, quadword, and halfword, also vary with the CPU and OS.
简而言之,一个字是 CPU 可以处理的一组固定长度的位。我们通常使用 2 次方的单词,因为现代 CPU 可以很好地处理这些单词。一个
word
特别是不是一个真正的数字,尽管我们在大多数情况下都是这样对待的。相反,只需将其视为您可以操作的 RAM 中的固定位数。 Word8
之类的常见用途例如,是实现 ASCII C 风格的字符串。 Haskell 的实现对待 WordN
类型为实现 Num
的无符号整数,以及其他类型类。有一个名为
Data.Ord
的模块其中“Ord”代表“排序”。它具有处理数据类型比较的额外功能,并且是 Ordering
的位置。数据类型和 Ord
类型类已定义。与 Data.Word
无关.
关于haskell - 为什么 Haskell 中的 Data.Word 是这样称呼的?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/22544720/