[Top][All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: bit-extract seems broken.
From: |
Jim Blandy |
Subject: |
Re: bit-extract seems broken. |
Date: |
19 Dec 2000 12:01:16 -0500 |
Dirk Herrmann <address@hidden> writes:
> On 18 Dec 2000, Rob Browning wrote:
>
> >
> > guile> (bit-extract #b111110100000 0 32)
> > 0
> > guile>
> >
> > or can it not return more than a limited range?
>
> I just wanted to fix it, but realized that it is not really clear to me
> what bit-extract should do with negative numbers. Opinions? Should we
> for example only allow non-negative arguments?
>
> Further, I stumbled across what I think is a gcc compiler error on sparc
> solaris: x << y or x >> y appears to always give the same results if
> y = a + b*32, no matter what b is. In other words, the shift operation
> only uses the last 5 bits of the operand. I assume that this does not
> conform to the C standard? If anyone can confirm this, I will send a bug
> report. (Hopefully there's no Klingon programmer responsible for that
> part of the compiler :-)
According to ISO C: "[i]f the value of the right operand [of a shift
operator] is negative or is greater than or equal to the width of the
promoted left operand, the behavior is undefined."
Negative values for the