Shift by negative quantity
Tom Stockfisch
tps at sdchem.UUCP
Wed Jul 9 02:23:12 AEST 1986
In article <894 at bu-cs.UUCP> bzs at bu-cs.UUCP (Barry Shein) writes:
>Question: Is shifting by a negative quantity defined (that is,
>probably means the other shift.) I could find no mention in K&R.
>...
Looking up "shift operators" in the index of K&R, I am referred to p. 189:
"The result [of a shift operator] is undefined if the right operand
is negative, or greater than or equal to the length of the object
in bits."
I'm sure its done this way so that the operation is closer to every machine's
instruction set and isn't a higher-level operation with additional checks
or conversions.
>P.S. Is this one of those questions that gets asked every 2 months?
I haven't seen it before.
--Tom Stockfisch, UCSD Chemistry
More information about the Comp.lang.c
mailing list