Relay-Version: version B 2.10 5/3/83; site utzoo.UUCP Path: utzoo!watmath!clyde!caip!topaz!uwvax!harvard!bu-cs!bzs From: bzs@bu-cs.UUCP (Barry Shein) Newsgroups: net.lang.c Subject: Shift by negative quantity Message-ID: <894@bu-cs.UUCP> Date: Fri, 4-Jul-86 22:02:37 EDT Article-I.D.: bu-cs.894 Posted: Fri Jul 4 22:02:37 1986 Date-Received: Sat, 5-Jul-86 08:55:00 EDT Organization: Boston Univ Comp. Sci. Lines: 26 Question: Is shifting by a negative quantity defined (that is, probably means the other shift.) I could find no mention in K&R. it came up with an expression like: foo = goo >> 10-PGSHIFT; which was a constant shift value. it didn't work on a SUN3, what's the poop? (seems hard for most code generators if it's variable, well, would have to test and branch if the underlying machine's shift instruction won't take negative values correctly so I wouldn't be surprised if it's undefined and I could understand not wanting a separate rule for a constant even though it would be easy to turn it around.) Therefore, I guess it's just not defined and you have to generate your own test, but I was wondering what was official. Of course, it accidently works right on a VAX and NS32k, great, more bugs to worry about...(a test example forcing negative, I know the above is positive on a VAX, that's the point ultimately.) -Barry Shein, Boston University P.S. Is this one of those questions that gets asked every 2 months? If so, I'm glad, maybe I'll get a good answer after all that practice :-)