Three Birds

COTTRELL, JAMES cottrell at nbs-vms.arpa
Fri Dec 6 06:16:14 AEST 1985


/*
> [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 at 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 at boring.UUCP> jack at 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 at nbs
*/
------



More information about the Comp.lang.c mailing list