question about shift operator

Guy Harris guy at auspex.UUCP
Wed Nov 9 04:30:35 AEST 1988


>Now, why is there any question as to the result?

Because:

	1) the intent was that shifts be implemented using the machine's
	   shift instructions, with as little extra decoration as
	   possible;

and

	2) some machines take the shift count modulo the word size,
	   and others don't, so some machines, when told to shift left
	   (word size) bits, will shift (word size) bits,
	   clearing the word, and others will shift left 0 bits.

The language spec specifically allows for this, by not specifying what
happens if you have a shift count >= (word size).



More information about the Comp.lang.c mailing list