From 8022d459e5f0862841236dc2bba4984a1395687c Mon Sep 17 00:00:00 2001 From: Danny Robson Date: Wed, 3 Feb 2016 13:56:40 +1100 Subject: [PATCH] maths: add samesign convenience function --- maths.hpp | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/maths.hpp b/maths.hpp index 5db3d158..fb48a823 100644 --- a/maths.hpp +++ b/maths.hpp @@ -292,6 +292,15 @@ namespace util { return std::signbit (t) ? -1 : 1; } + //------------------------------------------------------------------------- + template + constexpr + bool + samesign (T a, T b) + { + return a < 0 && b < 0 || a > 0 && b > 0; + } + /////////////////////////////////////////////////////////////////////////////// // factorisation