Re: C and side-effects

From: Kurt Roeckx (Q@ping.be)
Date: Thu May 04 2000 - 08:40:13 EST


On Thu, May 04, 2000 at 02:50:12AM -0700, George Anzinger wrote:
> I wrote:
>
> c = (c - d)>>n + d;

Are you sure you don't want c = (c - d >> n) + d;?

> and tested for values of 0 < c < 40, 1 < d < 40 and 0 < n < 80.

Are you sure what will happen if d is bigger then c? I have no idea if
that can be the case where you want to use it.
I have no idea what the standard says about shift with negative numbers,
but gcc always seems to do the same, wether it's signed or unsigned. -1 >>
32 still is -1. I assumed it would be 0 for unsigned, but I seem to be
wrong on this.

Kurt

-
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@vger.rutgers.edu
Please read the FAQ at http://www.tux.org/lkml/



This archive was generated by hypermail 2b29 : Sun May 07 2000 - 21:00:14 EST