Relay-Version: version B 2.10 5/3/83; site utzoo.UUCP
Path: utzoo!mnetor!uunet!husc6!cmcl2!brl-adm!umd5!mimsy!chris
From: chris@mimsy.UUCP (Chris Torek)
Newsgroups: comp.lang.c,comp.sys.ibm.pc
Subject: Re: What's Wrong here?
Message-ID: <9562@mimsy.UUCP>
Date: Sun, 29-Nov-87 12:52:35 EST
Article-I.D.: mimsy.9562
Posted: Sun Nov 29 12:52:35 1987
Date-Received: Wed, 2-Dec-87 20:53:32 EST
References: <278@westmark.UUCP> <6755@brl-smoke.ARPA> <6855@sunybcs.UUCP>
Organization: U of Maryland, Dept. of Computer Science, Coll. Pk., MD 20742
Lines: 35
Xref: mnetor comp.lang.c:5639 comp.sys.ibm.pc:10607

In article <6855@sunybcs.UUCP> ugfailau@sunybcs.uucp (Fai Lau) writes:
>	The left most bit of both long words of UNIX and Rel 3.0
>are sign bits. The same is true for the integer of Rel 4.0.
>When you "overshift" a word or integer, the sign bit can only
>be shifted "on". That is, when the sign bit is turned on as
>a result of bit shifting, it can not be turned off again, ....

This may be true for left shifts, although I doubt it.  It is
probably true for right shifts.

>	In the [original example], a 16 bit word is overshifted.
>What's left is a word with *only* the left most bit, the sign
>bit, turned on. This bit pattern represents an integer
>value of -65536 (I don't want to go into how the *value*
>of a negative number is represented).

Nonsense.  The pattern 0x8000 as a signed two's complement 16
bit value represents -32768.

>>By the way, you're treading on thin ice anyway, since (1L << 31) is
>>the most-negative 2's complement integer, so subtracting 1 from it
>>is yet another undefined operation.  [Doug Gwyn]

>	The operation is not undefine.

Again, nonsense.  The result is undefined *in C*.  No doubt the
operation on any given system is predictable (though possibly with
difficulty: a compiler is free to implement underflow by replacing
the value with the time of day, or the apparent diameter of the
lit region of the moon, or soemthing equally absurd).  Most will
ignore the underflow and change 0x80000000 to 0x7fffffff; others
may trap and give you a core dump.
-- 
In-Real-Life: Chris Torek, Univ of MD Comp Sci Dept (+1 301 454 7690)
Domain:	chris@mimsy.umd.edu	Path:	uunet!mimsy!chris