This thread has been locked.

If you have a related question, please click the "Ask a related question" button in the top right corner. The newly created question will be automatically linked to this question.

cast problems in F28377D



Hi all,

I have the following code:

unsigned long a;
long b;
long result;

After a and b are given by some values, I want

result = a - b;

If I explicitly express this expression using cast like the following:

result = (long)(a-b);

The compiler can still compile, but the result seems wrong.

I also tried casting like the following:

result = (long)(a-(unsigned long)b);

The compiler can still compile, but the result seems wrong.

But, if I do something like the following, the result is correct.

result = a-(unsigned long)b;