Mail Archives: djgpp/1998/06/29/15:49:30
"Arthur" <arfa AT clara DOT net> wrote:
> >In C you use << SHL and >> SHR
>
> You don't seem to understand what I mean. There is a fundamental difference
> between arethmetic and logical shifting. Arethmetic shifting shifts the data
> (bytes, words or longs) but keeps the sign bit intact. Logical shifting
> treats the sign bit as any other bit in the byte/word/long.
SHR/SHL are logical shift
SAL/SAR are arithmetic (Shift Arithmetic Left)
> So for instance, aretmetically shifting left the value -2 would give the
> result -4; logically shifting left -2 would give 4.
>
> Rolling takes any bits shifted off one end of the byte/word/long and sticks
> them on the other end.
ROR/ROL
> So rolling a byte right (logically) with the value of 1 would give the
> answer of 65664.
>
> The shift commands which change different bits that I was referring to are
> commands like "shift with carry" and "shift with overflow."
>
> AFAIK, you can only do arethmetic shifting in C, like I said.
No! if you apply >> and << to an unsigned you get logical stuff. The arithmetic
is used only for signeds.
SET
------------------------------------ 0 --------------------------------
Visit my home page: http://set-soft.home.ml.org/
or
http://www.geocities.com/SiliconValley/Vista/6552/
Salvador Eduardo Tropea (SET). (Electronics Engineer)
Alternative e-mail: set-soft AT usa DOT net set AT computer DOT org
ICQ: 2951574
Address: Curapaligue 2124, Caseros, 3 de Febrero
Buenos Aires, (1678), ARGENTINA
TE: +(541) 759 0013
- Raw text -