I am creating random integers with the following algorithm:
int random;
int i;
for (i = 0; i < RANDOM_COUNT; i++) {
random = (((int) rand() << 0) & 0x0000FFFFd)
| (((int) rand() << 16) & 0xFFFF0000d);
fprintf(outputFile, " %d\n", random);
}
I am getting the following warning:
warning: integer constant is too large for "long" type
on this line:
| (((int) rand() << 16) & 0xFFFF0000d);
I am using GCC 3.4.3 to compile the code.
Does anyone know which part of the operation is triggering the warning?
Yes, it’s the
0xFFFF0000d, because it’s 36 bits in size. Note that this number is equal to0xFFFF0000D. You probably meant0xFFFF0000.Likewise,
0x0000FFFFdis equal to0x0000FFFFD. You probably meant0x0000FFFF.