This discussion has been locked.
You can no longer post new replies to this discussion. If you have a question you can start a new discussion

variables with type unsigned long problem

Dear All:

When I compile the the code with
the statement:

The type of short_idx is unsigned short.
Row1= (short_idx * 64) >> 8 >>8;

If the value of short_idx is 2048, the
Row1 should be 2,but Row1 will be 0.

But if I change the statement to the
following.

Row1= ((unsigned long)short_idx * (unsigned long)64) >> 8 >>8;

Then Row1 would become 2 and is correct.

So what should I do in compiler to avoid of such problem without adding "unsigned long" in every statement I used in my problem?

Thank you ...