On Wed, Aug 20, 2008 at 1:30 PM, Peter Zijlstra <a.p.zijlstra@chello.nl> wrote:
I think you'd want to cast it with a (signed) instead? as in:
#include <stdio.h>
#define avg(x, y) ({ \
typeof(x) _x = (x); \
typeof(y) _y = (y); \
(void) (&_x == &_y); \
_x + (signed)(_y - _x)/2; })
int main (void) {
unsigned long long a=7,b=5;
printf("%d %d\n", avg(a,b), avg(b,a));
}
...which works here, for me, but hey, I managed to goof up my other
test case, so take it for a spin.
Ray
--