Another way (How not to write a loop)

John B. Nagle jbn at glacier.STANFORD.EDU
Sun Feb 21 05:15:17 AEST 1988


     Another classic problem is the fact that the difference between two
unsigned values is itself unsigned.  Thus,

     unsigned short a,b; 

     a = 1;
     b = 2;
     if (a - b < 0) printf("B smaller than A\n"); 

is invalid.  This particular strangeness caused an obscure bug in 4.3BSD
networking which prevented interoperation of 4.3BSD's TCP with some
other TCP implementations, including TOPS-20.



More information about the Comp.lang.c mailing list