#define MIN2( A, B ) ( (A)<(B) ? (A) : (B) )
#define MAX2( A, B ) ( (A)>(B) ? (A) : (B) )
-#define MIN3( A, B, C ) MIN2( MIN2( A, B ), C )
-#define MAX3( A, B, C ) MAX2( MAX2( A, B ), C )
+#define MIN3( A, B, C ) ((A) < (B) ? MIN2(A, C) : MIN2(B, C))
+#define MAX3( A, B, C ) ((A) > (B) ? MAX2(A, C) : MAX2(B, C))
-#define MIN4( A, B, C, D ) MIN2( MIN2( A, B ), MIN2(C, D) )
-#define MAX4( A, B, C, D ) MAX2( MAX2( A, B ), MAX2(C, D) )
+#define MIN4( A, B, C, D ) ((A) < (B) ? MIN3(A, C, D) : MIN3(B, C, D))
+#define MAX4( A, B, C, D ) ((A) > (B) ? MAX3(A, C, D) : MAX3(B, C, D))
/**