Re[2]: [XviD-devel] qpel - problems I found

Michael Niedermayer xvid-devel@xvid.org
Sat, 12 Oct 2002 16:41:39 +0200


Hi

On Saturday 12 October 2002 15:57, trbarry@trbarry.com wrote:
> | particular, it turns out that (dx >> 1) on a negative value works
> | correctly - ie divides by 2. So the difference is rounding. I don't
> | know if the value should be rounded or not...
>
> I have vague memories that the result of (dx >> 1) on signed numbers
> could be compiler dependent. But I don't remember where I read it.
iso c standart IIRC (possibly in the other c standarts too)

the problem IIRC is with negative numbers, for them the bit which is shifted 
in at the left is undefined so (-1)>>1 could be -1 or 0x7FFF or 0x7FFFFFFFF 
or somthing like that but in practice it seems to be allways -1 (i havnt seen 
any architecture where this wasnt true, and alot of code would break if 
(-1)>>1 != -1

(ffmpeg & libmpeg2 certainly wont work if >> does shift 0 in for negative 
numbers)

[...]

Michael