Path: utzoo!utgpu!news-server.csri.toronto.edu!cs.utexas.edu!samsung!uunet!mcsun!tuvie!vmars!hp From: hp@vmars.tuwien.ac.at (Peter Holzer) Newsgroups: comp.lang.c Subject: Re: shift left arithmetic Message-ID: <1807@tuvie> Date: 11 Sep 90 15:30:13 GMT References: <2098@charon.cwi.nl> <3973@bingvaxu.cc.binghamton.edu> <2101@charon.cwi.nl> <57871@iuvax.cs.indiana.edu> Sender: news@tuvie Lines: 24 bomgard@copper.ucs.indiana.edu (Tim Bomgardner) writes: >}#>I stumbled over the following: 1<<32 produced 0, but >}#>int a; a=1; a<<32 produced 1. (Of course the word length >For those who might be interested: >Microsoft C (5.1) produced different results depending on the use of 16 >or 32 bit integers, but at least one case would always produce a >non-zero result. Turbo C 2.0 always produced 0's in all cases. On the same computer? On the 8086, all bits of the bit count are significant, so the result should be 0. On a 80386, however only the rightmost 5 bits are taken, so the result should be 1 (Of course the 8086 only has 16 bit words, so 32bit shifts are done by a library function, which might mask out all but the lower 5 bits; and neither TC 2.0 nor MSC 5.1 can produce 80386 code, so a 32bit shift is never done in one instruction with these compilers). -- | _ | Peter J. Holzer | Think of it | | |_|_) | Technische Universitaet Wien | as evolution | | | | | hp@vmars.tuwien.ac.at | in action! | | __/ | ...!uunet!mcsun!tuvie!vmars!hp | Tony Rand |