Right shift vs. divide

Herb Kanner kanner at tymix.UUCP
Thu Dec 26 07:09:09 AEST 1985


In article <974 at brl-tgr.ARPA> Schauble at mit-multics.arpa (Paul Schauble) writes:

>BTW, is >> defined to be a sign-extended shift or a zero extended shift
>and under what circumstances.
>  
I'm doing this at home from memory, without a copy of K & R at hand, so,
please, no flames if I get it slightly wrong.

My recollection of their definition of >> is that if the shifted variable
is of type unsigned, it must be a zero-extended shift.  If the shifted
variable is of type int, it may be sign extended if the underlying
hardware possesses such an instruction--I think this is a relatively
non-commital way of saying that it will probably be implemented as a
sign-extended shift on machines using two-complement notation for negative
numbers.

-- 
Herb Kanner
Tymnet, Inc.
...!hplabs!oliveb!tymix!kanner



More information about the Comp.lang.c mailing list