From e40f70a3af1142e6c0c89c6ea2ee47b996495661 Mon Sep 17 00:00:00 2001 From: Stijn Buys Date: Mon, 20 Sep 2010 16:30:45 +0000 Subject: corrected trading inconsistencies, improved trade window, initial slider widget --- src/math/functions.cc | 20 ----------------- src/math/functions.h | 60 ++++++++++++++++++++++++++++++++++++++++++++------- 2 files changed, 52 insertions(+), 28 deletions(-) (limited to 'src/math') diff --git a/src/math/functions.cc b/src/math/functions.cc index 7fb40be..7c95a79 100644 --- a/src/math/functions.cc +++ b/src/math/functions.cc @@ -12,26 +12,6 @@ namespace math const float DELTA = 10e-10; -float min(float a, float b) -{ - return (a < b ? a : b); -} - -float max(float a, float b) -{ - return (a > b ? a : b); -} - -int min(int a, int b) -{ - return (a < b ? a : b); -} - -int max(int a, int b) -{ - return (a > b ? a : b); -} - float randomf(const float max) { return ((float) rand() / (float) RAND_MAX) * max; diff --git a/src/math/functions.h b/src/math/functions.h index 5a53d44..8135392 100644 --- a/src/math/functions.h +++ b/src/math/functions.h @@ -15,17 +15,53 @@ namespace math { -/// return the smallest of two float values -float min(float a, float b); +/** + * @brief return the smallest of two floats + */ +inline const float min(const float a, const float b) +{ + return (a < b ? a : b); +} -/// return the smallest of two integers -int min(int a, int b); +/** + * @brief return the smallest of two integers + */ +inline const int min(const int a, const int b) +{ + return (a < b ? a : b); +} -/// return the largest of two float values -float max(float a, float b); +/** + * @brief return the smallest of two longs + */ +inline const long min(const long a, const long b) +{ + return (a < b ? a : b); +} -/// return the largest of two integers -int max(int a, int b); +/** + * @brief return the largest of two floats + */ +inline const float max(const float a, const float b) +{ + return (a > b ? a : b); +} + +/** + * @brief return the largest of two integers + */ +inline const int max(const int a, const int b) +{ + return (a > b ? a : b); +} + +/** + * @brief return the largest of two longs + */ +inline const long max(const long a, const long b) +{ + return (a > b ? a : b); +} /// returns a random float /** The value returned will be in the interval [0-max] @@ -63,6 +99,14 @@ inline float absf(const float f) return ( f < 0.0f ? -f : f ); } +/// swap two float values +inline void swap(float &x, float &y) +{ + float tmp = x; + x = y; + y = tmp; +} + } // namespace math #endif // __INCLUDED_MATH_FUNCTIONS_H__ -- cgit v1.2.3