diff --git a/glm/core/type_half.inl b/glm/core/type_half.inl index ec71fd16..68c333ad 100644 --- a/glm/core/type_half.inl +++ b/glm/core/type_half.inl @@ -275,27 +275,6 @@ namespace detail return static_cast(this->toFloat()); } - // Cast - //GLM_FUNC_QUALIFIER half::operator float() - //{ - // return toFloat(); - //} - - //GLM_FUNC_QUALIFIER thalf::operator float() const - //{ - // return toFloat32(this->data); - //} - - //GLM_FUNC_QUALIFIER half::operator double() - //{ - // return double(toFloat()); - //} - - //GLM_FUNC_QUALIFIER half::operator double() const - //{ - // return double(toFloat()); - //} - // Unary updatable operators GLM_FUNC_QUALIFIER thalf& thalf::operator= (thalf const & s) { @@ -330,14 +309,14 @@ namespace detail GLM_FUNC_QUALIFIER thalf& thalf::operator++() { float Casted = toFloat32(data); - data = toFloat16(++Casted); + this->data = toFloat16(++Casted); return *this; } GLM_FUNC_QUALIFIER thalf& thalf::operator--() { float Casted = toFloat32(data); - data = toFloat16(--Casted); + this->data = toFloat16(--Casted); return *this; } diff --git a/test/core/core_type_half.cpp b/test/core/core_type_half.cpp index 0e4d3d21..07679679 100644 --- a/test/core/core_type_half.cpp +++ b/test/core/core_type_half.cpp @@ -72,15 +72,47 @@ int test_half_arithmetic_unary_ops() { int Error = 0; - glm::half A(2.0f); - glm::half B(3.0f); + { + glm::half A(2.0f); + glm::half B(3.0f); + A += B; + Error += (A == glm::half( 5.0f) ? 0 : 1); + } - Error += A + B == glm::half( 5.0f) ? 0 : 1; - Error += A - B == glm::half(-1.0f) ? 0 : 1; - Error += B - A == glm::half( 1.0f) ? 0 : 1; - Error += A * B == glm::half( 6.0f) ? 0 : 1; - Error += A / B == glm::half(2.0f / 3.0f) ? 0 : 1; - Error += B / A == glm::half(3.0f / 2.0f) ? 0 : 1; + { + glm::half A(2.0f); + glm::half B(3.0f); + A -= B; + Error += (A == glm::half(-1.0f) ? 0 : 1); + } + + { + glm::half A(2.0f); + glm::half B(3.0f); + B -= A; + Error += (B == glm::half( 1.0f) ? 0 : 1); + } + + { + glm::half A(2.0f); + glm::half B(3.0f); + A *= B; + Error += (A == glm::half(6.0f) ? 0 : 1); + } + + { + glm::half A(2.0f); + glm::half B(3.0f); + A /= B; + Error += (A == glm::half(2.0f / 3.0f) ? 0 : 1); + } + + { + glm::half A(2.0f); + glm::half B(3.0f); + B /= A; + Error += (B == glm::half(3.0f / 2.0f) ? 0 : 1); + } return Error; } @@ -102,6 +134,48 @@ int test_half_arithmetic_binary_ops() return Error; } +int test_half_arithmetic_counter_ops() +{ + int Error = 0; + + { + glm::half A(2.0f); + Error += A == glm::half(2.0f) ? 0 : 1; + } + + { + glm::half A(2.0f); + glm::half B = A++; + Error += B == glm::half(3.0f) ? 0 : 1; + } + + { + glm::half A(2.0f); + glm::half B = A--; + Error += B == glm::half(1.0f) ? 0 : 1; + } + + { + glm::half A(2.0f); + glm::half B = ++A; + Error += B == glm::half(3.0f) ? 0 : 1; + } + + { + glm::half A(2.0f); + glm::half B = --A; + Error += B == glm::half(1.0f) ? 0 : 1; + } + + { + glm::half A(2.0f); + glm::half B = -A; + Error += B == glm::half(-2.0f) ? 0 : 1; + } + + return Error; +} + int main() { int Result = 0; @@ -111,6 +185,7 @@ int main() Result += test_half_relational(); Result += test_half_arithmetic_unary_ops(); Result += test_half_arithmetic_binary_ops(); + Result += test_half_arithmetic_counter_ops(); return Result; }