Integer Types
Randall Maas 7/9/2011 3:58:06 PM
This is mostly an update to the previous post wherein I described integer types, especially those with specific sizes.
Since then I found an excellent article titled "Everything you ever wanted to know about C types" by Peter Seebach:
Short version:
- Not all integer types are available. This is not surprising. Mr Seebach helps outline which macros to check for to see if they are.
- Types for the machines preferred integer types. (This is usually called word size, but I'm cautious with that. First, different units in the processor often have different word sizes. Second, many people used to Intel processors think of "WORD" as 16 bits, "DWORD" as 32 bits... and the modern Intel processor has a word size of 32 or 64 bits...)
- A mechanism to find the largest available integer size
And a whole slew of other info (worth a topic for another time) including pointers:
- Did you know that many different pointers "values" can be equal to a null pointer - not just
(void*) 0
? These are null pointers..
- Did you know that its possible for a pointer, after a free()?
- Base-2 isn't really required for integers - you could use gray code, for instance - but everyone assumes base-2 for integers...
- That many types define "trap" values, that when used have undefined behaviour (and may cause some sort of fault)? (Null pointers and divide by zero aren't part a structure definition now, I supposed)