osargs functions and 32 bit values
David Bryan
D.J.Bryan at cranfield.ac.uk
Fri Aug 25 20:08:49 BST 2000
Jonathan Coxhead wrote:
> On 23 Aug 00, at 19:41, Chris Rutter wrote:
>
> | An off-topic question: if `UINT_MAX' was 0xffffffffu, and I took the
> | number 0xf0f0f0f0 and shifted it left by 8 places, would ANSI guarantee me
> | that those eight most significant bits would simply be discarded, or do I,
> | /strictly speaking/, have to AND with a protective mask first?
> |
> | (I could look this up but I suspect Jon will know. ;-)
>
> I'd have to look it up too, because the answer's more complicated than
> you might have thought. The question is, what type is 0xF0F0F0F0? It's not
> int, because it doesn't fit. There are some complicated rules to decide
> what it is, but (without checking) I think it's unsigned int. Therefore,
> all operations work modulo 2^^32, and the answer is 0xF0F0F000. If the type
> of 0xF0F0F0F0 *was* int (i e, if an int with that value was shifted), the
> answer would be undefined (I think).
As the constant 0xf0f0f0f0 doesn't have a suffix, the choices go
int -> long int -> unsigned long int
As I can't think of a compiler for the ARM which doesn't have both
32bit ints and long ints, unsigned int seems close enough. (Both
the ARM and gcc compilers use "long long" to denote 64bits.)
--
David Bryan
More information about the oslib-user
mailing list