From dca96fd21dafcae11f9da160ca2586f84c8c2d31 Mon Sep 17 00:00:00 2001 From: Pavel Kirienko Date: Wed, 27 Aug 2014 15:58:28 +0400 Subject: [PATCH] libuavcan: Extended numeric traits --- libuavcan/include/uavcan/util/templates.hpp | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/libuavcan/include/uavcan/util/templates.hpp b/libuavcan/include/uavcan/util/templates.hpp index 4453e435c0..79bfdc41b2 100644 --- a/libuavcan/include/uavcan/util/templates.hpp +++ b/libuavcan/include/uavcan/util/templates.hpp @@ -393,6 +393,7 @@ struct UAVCAN_EXPORT NumericTraits static float max() { return FLT_MAX; } static float min() { return FLT_MIN; } static float infinity() { return INFINITY; } + static float epsilon() { return FLT_EPSILON; } }; /// double @@ -404,8 +405,10 @@ struct UAVCAN_EXPORT NumericTraits static double max() { return DBL_MAX; } static double min() { return DBL_MIN; } static double infinity() { return static_cast(INFINITY) * static_cast(INFINITY); } + static double epsilon() { return DBL_EPSILON; } }; +#if defined(LDBL_MAX) && defined(LDBL_MIN) && defined(LDBL_EPSILON) /// long double template <> struct UAVCAN_EXPORT NumericTraits @@ -415,6 +418,8 @@ struct UAVCAN_EXPORT NumericTraits static long double max() { return LDBL_MAX; } static long double min() { return LDBL_MIN; } static long double infinity() { return static_cast(INFINITY) * static_cast(INFINITY); } + static long double epsilon() { return LDBL_EPSILON; } }; +#endif }