Unsigned and Bitwise Operators
    CusterDD 
    ddc at druak.UUCP
       
    Tue Jun 26 05:59:48 AEST 1984
    
    
  
<munch>
The following program always reports -1 is negative, -1 is positive
on UNIX 5.05 running on VAX-11/780, 3B20 and 3B2.
I used the cc compiler
=============
#include <stdio.h>
main()
{
	char	foo;
	unsigned char ufoo;
	
	foo = ufoo = 1;
	if ((-1 | foo) < 0) printf("-1 is negative");
	if ((-1 | ufoo) > 0) printf("-1 is positive");
}
==============
If the ufoo test were to read:
	if ((-1 | ufoo) < 0) printf("-1 is positive");
then the printf would not be executed.
David Custer
AT&T Information Systems Labs
(303) 538-3517
{druak | druky | druxp}!ddc
UNIX is a trademark of AT&T Bell Laboratories
    
    
More information about the Comp.unix.wizards
mailing list