From 3f327d5e7017c988198be506f0e33e1acb564121 Mon Sep 17 00:00:00 2001 From: Christophe Riccio Date: Sun, 16 Mar 2014 12:33:00 +0100 Subject: [PATCH] Fixed usubBorrw --- glm/detail/func_integer.inl | 6 +++--- readme.txt | 1 + test/core/core_func_integer.cpp | 26 +++++++++++++++++++++----- 3 files changed, 25 insertions(+), 8 deletions(-) diff --git a/glm/detail/func_integer.inl b/glm/detail/func_integer.inl index ee010146..e792461d 100644 --- a/glm/detail/func_integer.inl +++ b/glm/detail/func_integer.inl @@ -110,10 +110,10 @@ namespace glm GLM_STATIC_ASSERT(sizeof(uint) == sizeof(uint32), "uint and uint32 size mismatch"); Borrow = x >= y ? static_cast(0) : static_cast(1); - if(x > y) - return static_cast(static_cast(x) - static_cast(y)); + if(y >= x) + return y - x; else - return static_cast((static_cast(1) << static_cast(32)) + static_cast(x) - static_cast(y)); + return static_cast((static_cast(1) << static_cast(32)) + (static_cast(y) - static_cast(x))); } template <> diff --git a/readme.txt b/readme.txt index 0ec0e353..3ad50114 100644 --- a/readme.txt +++ b/readme.txt @@ -48,6 +48,7 @@ GLM 0.9.5.3: 2014-0X-XX - Added support for all extensions but GTX_string_cast to CUDA - Fixed strict aliasing warnings in GCC 4.8.1 / Android NDK 9c (#152) - Fixed missing bitfieldInterleave definisions +- Fixed usubBorrow (#171) ================================================================================ GLM 0.9.5.2: 2014-02-08 diff --git a/test/core/core_func_integer.cpp b/test/core/core_func_integer.cpp index d1fcec87..1380f4a3 100644 --- a/test/core/core_func_integer.cpp +++ b/test/core/core_func_integer.cpp @@ -197,14 +197,14 @@ namespace findLSB genType Value; genType Return; }; - + type const DataI32[] = { {0x00000001, 0}, - {0x00000003, 0}, - {0x00000002, 1} + {0x00000003, 0}, + {0x00000002, 1} }; - + int test() { int Error(0); @@ -215,11 +215,27 @@ namespace findLSB Error += DataI32[i].Return == Result ? 0 : 1; assert(!Error); } - + return Error; } }//findLSB +namespace usubBorrow +{ + int test() + { + int Error(0); + + glm::uint x = 16; + glm::uint y = 17; + glm::uint Borrow = 0; + glm::uint Result = glm::usubBorrow(x, y, Borrow); + + return Error; + } + +}//namespace usubBorrow + int main() { int Error = 0;