3

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?

1 Answer 1

5

Does anyone know which part of the operation [(((int) rand() << 16) & 0xFFFF0000d);] is triggering the warning?

Yes, it's the 0xFFFF0000d, because it's 36 bits in size. Note that this number is equal to 0xFFFF0000D. You probably meant 0xFFFF0000.

Likewise, 0x0000FFFFd is equal to 0x0000FFFFD. You probably meant 0x0000FFFF.

Sign up to request clarification or add additional context in comments.

Comments

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.