diff --git a/glm/detail/func_integer.inl b/glm/detail/func_integer.inl index d0f6a84d5..67177a055 100644 --- a/glm/detail/func_integer.inl +++ b/glm/detail/func_integer.inl @@ -196,19 +196,19 @@ namespace detail GLM_FUNC_QUALIFIER uint usubBorrow(uint const& x, uint const& y, uint & Borrow) { Borrow = x >= y ? static_cast(0) : static_cast(1); - if(x >= y) - return x - 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 GLM_FUNC_QUALIFIER vec usubBorrow(vec const& x, vec const& y, vec& Borrow) { Borrow = mix(vec(1), vec(0), greaterThanEqual(x, y)); - vec const XgeY(x - y); - vec const YgX(vec((static_cast(1) << static_cast(32)) + (vec(x) - vec(y)))); - return mix(YgX, XgeY, greaterThanEqual(x, y)); + vec const YgeX(y - x); + vec const XgeY(vec((static_cast(1) << static_cast(32)) + (vec(y) - vec(x)))); + return mix(XgeY, YgeX, greaterThanEqual(y, x)); } // umulExtended