| PLEX86 | ||
Thou shalt have no other gods before the ANSI C standard 1637Thou shalt have no other gods before the ANSI C standard 1640 I have an Alpha running Tru64 in my cube right now (along with several x86 boxes and an Opteron system, but only one x86 box and the Alpha are running all the...
Anyway, you can always use the good old preprocessor to circumvent the problem. If you want an unsigned type with exactly 32 bits: * ================================================================= * #ifdef UINT32MAX typedef uint32t uint32exact; #else #define NOEXACT32 #endif #else #if UINTMAX == 0xFFFFFFFFUL typedef unsigned int uint32exact; #elif ULONGMAX == 0xFFFFFFFFUL typedef unsigned long uint32exact; #else #define NOEXACT32 #endif #endif #ifdef NOEXACT32 #error There is no unsigned type with exactly 32 bits. #endif Thou shalt have no other gods before the ANSI C standard 1638 Well, then the C standard does not agree with you about what "two's-complement" means. Since this is about a C program, and the documentation is there to help readers understand unambiguously... * ================================================================= * You store this somewhere in a common header file, and there you go. This works real well in practice. Note that I still recommand to use a type with at least 32 bits (which is selected in a similar way, so that a type with exactly 32 bits is used if possible) and include explicit truncations in the code: this makes source code more readable. Moreover, if this code is in a common header file, you have a single file to modify if you want to tweak it, or, for instance, try a longer type, just to get sure that you included the correct explicit truncations. Thou shalt have no other gods before the ANSI C standard 1639 Thomas lovein The mathematical function is defined for any length. The software API is limited to a gigabyte. I haven't seen... An enhanced version of this header also defines some macros for it if necessary). Memory accessors (which implement big-endian and little-endian storage for various data types) can also be defined such, as macros or inline functions: thus, the code is completely generic, and it is only a matter of tweaking a single file to get the "optimized" version, if needed. --Thomas lovein
|
||||
Thou shalt have no other gods before the ANSI C standard 1638 Alt Folklore Computers from Newsgroups The #1 Usenet Provider on the Internet
Thou shalt have no other gods before the ANSI C standard 1636 |
||||