43 #define declare_binary_minmax(Type) \
44 static Type min(Type a, Type b); \
45 static Type max(Type a, Type b)
47 #define implement_binary_minmax(Type) \
48 inline Type Math::min(Type a, Type b) { return a < b ? a : b; } \
49 inline Type Math::max(Type a, Type b) { return a > b ? a : b; }
51 #define declare_4_minmax(Type) \
52 static Type min(Type a, Type b, Type c, Type d); \
53 static Type max(Type a, Type b, Type c, Type d)
60 #define implement_4_minmax(Type) \
61 inline Type Math::min(Type a, Type b, Type c, Type d) { \
62 Type r1 = min(a, b), r2 = min(c, d); \
66 inline Type Math::max(Type a, Type b, Type c, Type d) { \
67 Type r1 = max(a, b), r2 = max(c, d); \
84 static long abs(
long);
85 static double abs(
double);
88 static int round(
double);
90 static bool equal(
float x,
float y,
float e);
91 static bool equal(
double x,
double y,
double e);
105 inline int Math::round(
float x) {
return x > 0 ? int(x+0.5) : -int(-x+0.5); }
106 inline int Math::round(
double x) {
return x > 0 ? int(x+0.5) : -int(-x+0.5); }
109 return x - y <
e && y - x <
e;
113 return x - y <
e && y - x <
e;
declare_binary_minmax(double)
declare_binary_minmax(long)
declare_binary_minmax(unsigned)
declare_binary_minmax(unsigned long)
static bool equal(float x, float y, float e)
declare_binary_minmax(float)
declare_binary_minmax(int)
#define implement_4_minmax(Type)
#define implement_binary_minmax(Type)