On Tue, Dec 20, 2005 at 07:54:08PM -0800, Andrew Pimlott wrote: > On Tue, Dec 20, 2005 at 10:40:20PM -0500, Justin Pryzby wrote: > > It has more to do with the processor than the language; this is not at > > all specific to this structure, or to C. I think it is nearly-true > > that all processors work natively with "2s complement" integers (and > > IEEE floats). Processors are either "big endian" or "little endian" > > (except for PDP :) > > > > So for int i=(int)0xffff, the result will be assignment to _i_ of the > > number 65535, which is of course represented as 0x0000ffff. They are > > both stored as 00000000000000001111111111111111 (or > > 11111111111111110000000000000000, depending on endianness). > > s_port is specified as big-endian. Oh, I didn't see that. Then you have to call ntohs() on it before doing any arithmetic operations on it, or interpretting it as an integer, as in your test.
-- Clear skies, Justin -- To UNSUBSCRIBE, email to [EMAIL PROTECTED] with a subject of "unsubscribe". Trouble? Contact [EMAIL PROTECTED]