Path: utzoo!attcan!uunet!pcrat!rick From: rick@pcrat.UUCP (Rick Richardson) Newsgroups: comp.arch Subject: Re: Shifting question Message-ID: <529@pcrat.UUCP> Date: 19 Jul 88 11:41:37 GMT References: <705@bnr-rsc.UUCP> <392@attila.weitek.UUCP> Reply-To: rick@pcrat.UUCP (Rick Richardson) Organization: PC Research, Inc., Tinton Falls, NJ Lines: 21 In article <392@attila.weitek.UUCP> mahar@attila.UUCP (Mike Mahar) writes: >The question (x>>32) has come up. K&R and ANSI-C say the result is undefined. >The 68000 shift instruction will give you a 0. >The 80286 shift instruction will give you a 0. This depends upon your 80286 compiler, whether x is an int or a long, and whether you try shift 16 or 32 bits. The AT&T 80286 compiler (GET THIS!) actually detects: some_long >> 32 some_int >> 32 and explicity generates code to give the result as "some_long" or "some_int"! At first, I thought this implementation choice was for consistency with the case where the shift count is a variable. But alas, if x is "32": some_long >> x gives result "0" some_int >> x gives result "some_int" So this compiler isn't even consistent in its treatment of this problem. -- Rick Richardson, PC Research, Inc. (201) 542-3734 (voice, nights) OR (201) 389-8963 (voice, days) uunet!pcrat!rick (UUCP) rick%pcrat.uucp@uunet.uu.net (INTERNET)