Yuor problem is due to the fact that other compilers returns a short as result (16bits integer max positive value=32768). PellesC returns a real 32 bits int that is equivalent to long (32 bits).
To let work the code just change the casting to long:
/****** snippet from comp.lang.c ******/
#ifndef __TURBOC__
#define random( num ) ( int ) ((( (long long)rand()) * ( long long ) ( num )) / ((( long long ) RAND_MAX ) + 1 ))
#define randomize() srand(( unsigned ) time( NULL ) | 1 )
#endif
int main( void )
{
unsigned long long int x, y, z; // 64 bit, right?
int i;
randomize();
x = RAND_MAX;
printf("That's RAND_MAX : %llu (0x%x)", x, x );
getchar();
for (i=0; i<52; i++)
printf("This number should be random in the interval from 0 to 52 : %d\n", random( 52 ));
getchar();
/****** now i do the same as the random macro ******/
y = (long long)rand() * 52; // 52 is the max number i want
x += 1;
z = (long long int) ((long long)y / x); // convert double for division and convert back? Error?
printf("The result of %llu divided by %llu results in %llu ?", y, x, z );
getchar();
return( 0 );
}
Or if you prefer reduce the rand output to 16 bits. The last will let increase the frequency for lower values in requested interval.