Re: [IDEA+RFC] Possible solution for min()/max() war

Herbert Rosmanith (herp@wildsau.idv-edu.uni-linz.ac.at)
Thu, 30 Aug 2001 22:44:07 +0200 (MET DST)


> if sizeof(typeof(a)) != sizeof(typeof(b))
> BUG() // sizes differ

this is not neccessarily a problem. should work with char/short char/int
short/int comparison.

only problem seems to be signed/unsigned int comparison.

> const (typeof(a)) _a = ~(typeof(a))0
> const (typeof(b)) _b = ~(typeof(b))0
> if _a < 0 && _b > 0 || _a > 0 && b < 0
> BUG() // one signed, the other unsigned
> standard_max(a,b)

if sizeof(typeof(a))==sizeof(int) && sizeof(typeof(b))==sizeof(int) &&
( _a < 0 && _b > 0 || _a > 0 && b < 0 )
BUG() // signed unsigned int compare

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