Path: utzoo!attcan!uunet!seismo!sundc!pitstop!sun!quintus!ok From: ok@quintus.uucp (Richard A. O'Keefe) Newsgroups: comp.lang.c Subject: Re: "for" loops in C ... Message-ID: <651@quintus.UUCP> Date: 9 Nov 88 04:19:07 GMT References: <867@cernvax.UUCP> <645@quintus.UUCP> <339@igor.Rational.COM> Sender: news@quintus.UUCP Reply-To: ok@quintus.UUCP (Richard A. O'Keefe) Organization: Quintus Computer Systems, Inc. Lines: 21 In article <339@igor.Rational.COM> dsb@Rational.COM (David S. Bakin) continues asking about "<<". >The operator << is defined in C as a left shift, ... Nope. << is defined to be whatever C defines it to be, and C leaves it as vague as possible to make it easy for compiler writers to generate fast code. (There is something just slightly crazy about this.) It has nothing to do with the VAX as such. We can define shifting for signed integers as X << Y = floor(X * 2**Y) which definition works beautifully for all values of X and Y. Alas, that's not what the hardware does on _any_ machine that I know of (the VAX comes *closest*.) Some machines take the bottom 5 bits. Some take the bottom 6. Some haven't _got_ a left shift instruction. (For example, on the M88000, the simplest translation of X<= BITS_PER_BYTE*sizeof X ? 0 : X>>Y; (assuming that you are happy to have result undefined when Y < 0).