From 7def3377811e68753820fb59be426f11c09f9922 Mon Sep 17 00:00:00 2001 From: plasmacel Date: Thu, 20 Nov 2014 15:33:28 +0100 Subject: [PATCH] Update func_common.inl --- glm/detail/func_common.inl | 13 +++---------- 1 file changed, 3 insertions(+), 10 deletions(-) diff --git a/glm/detail/func_common.inl b/glm/detail/func_common.inl index 1a00ff50..9c55c7a1 100644 --- a/glm/detail/func_common.inl +++ b/glm/detail/func_common.inl @@ -151,22 +151,15 @@ namespace detail } // sign - //Try something like based on x >> 31 to get the sign bit + // fast and works for any type template GLM_FUNC_QUALIFIER genFIType sign(genFIType x) { GLM_STATIC_ASSERT( std::numeric_limits::is_iec559 || (std::numeric_limits::is_signed && std::numeric_limits::is_integer), "'sign' only accept signed inputs"); - - genFIType result; - if(x > genFIType(0)) - result = genFIType(1); - else if(x < genFIType(0)) - result = genFIType(-1); - else - result = genFIType(0); - return result; + + return genFIType(genFIType(0) < x) - (x < genFIType(0)); } template class vecType>