I’m trying to implement George Marsaglia’s Complementary Multiply-With-Carry algorithm in C. It seems to work great under Win7 64 bit and Linux 32 bit, but seems to behave strangely under Win 7 32 bit. The random number it returns is 32 bit, but there’s a temporary value used internally that’s supposed to be 64 bits, and it’s declared:
unsigned long long t;
I suspect this might be the cause of the misbehaviour, so my question is:
Is the type “long long” 64 bits? Is it supported in 32 bit Windows?
The type
long longis guaranteed to be at least 64 bits (although the guarantee is formally in the form of the range of values it must be able to represent).The following is in §5.2.4.2.1 of the C99 standard (link to draft):