Hi,
Ok. I only want to know why the following two cases have different results :
Case 1:
unsigned short number1 = 1;
signed short number2 = 1;
if(ISUNSIGNED(number1))
{
printf("number 1 is unsigned \n");
}
if(ISUNSIGNED2(number2))
{
printf("number 2 is unsigned\n");
}
No printout and seemed that it can't figure out variable unsigned .
Case 2:
unsigned int number1 = 1;
signed int number2 = 1;
if(ISUNSIGNED(number1))
{
printf("number 1 is unsigned \n");
}
if(ISUNSIGNED2(number2))
{
printf("number 2 is unsigned\n");
}
Printout: number1 is unsigned. It works!
Bests,
Zoe
"Chris Dollin" <ch**********@hp.comwrote in message
news:en**********@murdoch.hpl.hp.com...
Z-Z wrote:
>I used the following macro to determine variable signed or not, but only
find that it is useless for a short or char variable. I think that it
might
caused by value conversion rules. I used VC.
#define ISUNSIGNED(a) (a>=0 && ~a>= 0)
Who knows the reason and other methods to determine short varible signed
or
not?
I read the code.
What on Earth are you trying to do that depends on whether a short is
signed or not? It feels ... fragile. Maybe if you explained the
actual problem we could offer a more robust solution.
--
Chris "hopefully not Pyecroft" Dollin
A rock is not a fact. A rock is a rock.