Relay-Version: version B 2.10 5/3/83; site utzoo.UUCP Posting-Version: version B 2.10.2 9/18/84; site brl-tgr.ARPA Path: utzoo!watmath!clyde!burl!ulysses!allegra!mit-eddie!think!harvard!seismo!brl-tgr!tgr!cottrell@nbs-vms.arpa From: cottrell@nbs-vms.arpa (COTTRELL, JAMES) Newsgroups: net.lang.c Subject: Three Birds Message-ID: <368@brl-tgr.ARPA> Date: Thu, 5-Dec-85 15:16:14 EST Article-I.D.: brl-tgr.368 Posted: Thu Dec 5 15:16:14 1985 Date-Received: Sat, 7-Dec-85 04:36:57 EST Sender: news@brl-tgr.ARPA Lines: 62 /* > [Replying to an article about Jim Cotrell's new machine] > One problem. Does the ANSI standard specify what left- > and right-shifts do, w.r.t. arithmatic values? And &|!^ etc? > > :-), of course. Followups on boolean arithmatic (if you can call it > that) on terniary machines should go to net.arch. > -- > Jack Jansen, jack@mcvax.UUCP Left & right shifts are well defined, altho not what you might think. In base two machines, each `bit' (binary digit) is shifted into the next one, effectively muliplying (or dividing with truncation) by two. In our base three each `twit' (twiple digit) is shifted into its next one, thus multiplying (or dividing) by three. I don't know *what* `&', `|', or `^' do. `!' is the same, as is `~'. Doug Gwyn: > Most C applications have no need to use bitwise operators. > && || and ! are well-defined for any arithmetic quantity, > regardless of the base. Bit operations are certainly > useful at times, such as when twiddling device registers > or when writing bitmap display code, but I feel they are > often used when they're not appropriate. Thanx for saying that. To my horror I realized that (x * 2) != (x << 1) when used on negative numbers on one's complement machines!!! This is not portable!!! (Can you believe *I* said that?!? :-) > If anyone is seriously interested in ternary bases, check > out Vol. 2 of Knuth. Okay, I think I might. Joe Yao: > In article <6698@boring.UUCP> jack@boring.UUCP (Jack Jansen) writes: > > One problem. Does the ANSI standard specify what left- > >and right-shifts do, w.r.t. arithmatic values? And &|!^ etc? > > I believe that this falls under the heading, "say what you mean." > If you m e a n that bits should shift left, say so; if you instead > m e a n that you wish to multiply (resp., divide); say that, also! > Your compiler (at least, with optimisation on) should be able to do > the conversion if it speeds anything up; and future generations of > software maintenance personnel will sing your praises for doing > something in a way that is comprehensible to both man and machine. I used to do that until I found out that the opti-miser does it for me. Fortunately I didn't do it on an 1108. > >>Is it after midnight yet? ;-)<< You know those plaques with a clock with all 5's that says: `No drinking until after Five'? I'm going to send you one with all twelves that says: `No posting after midnight' :-) jim cottrell@nbs */ ------