What does "integral type" mean?
Raymond Chen said at his blog,
开发者_高级运维The integral types WPARAM, LPARAM, and LRESULT are 32 bits wide on 32-bit systems and 64 bits wide on 64-bit systems. What happens when a 32-bit process sends a message to a 64-bit window or vice versa?
Why did he use the term 'integral types'?. I haven't heard it yet.
What does it mean?Integral types are data types which store integer numbers. ie distinct from floating point data type, strings, etc.
Why does he use the term here?
These data types have a particular property due to their structure, which means that they will have different storage capacities on systems with different 'word' sizes (a 'word' being a chunk of data which the computer can access in one go: ie 32 bits on a 32-bit processor, 64 bits on a 64-bit processor, etc).
Virtually all integer data in a computer is stored in whole 'words', and he is explaining that integer data types will vary in size according to the host computer.
He didn't really need to use the word 'integral'; simply listing the affected data types as he does is sufficient to tell you that these data types behave in this way. But by adding the word 'integral' to the sentence, he is implicitly emphasising the reason why they work this way.
(I guess this is as much of a linguistic question as a programming one)
A type whose value is an integer.
Martyn
An integral type is "like" an integer, i.e. its values are whole numbers. The standard C integral types are all the flavours of int
and char
, and also pointers (because pointers are just numbers, namely memory addresses).
At machine level, integral values are typically handles in the CPU's main general purpose registers. Contrast this to "floating point" values, which are typically handled in a different set of registers, and whose binary expression is not directly related to its value.
I guess in total you have four sorts of types: integral, floating point and compound (structs etc.), and arrays.
精彩评论