From 5481aa70978bb14f3a718b5fc4b97b9489cf2c59 Mon Sep 17 00:00:00 2001 From: Fraser Waters Date: Mon, 2 Jun 2014 11:16:43 +0100 Subject: [PATCH] Fix a bug in single->half conversion. The original C code had if(m & 0x00800000) which is true if the expresssion does not evaluate to zero. This was inncorretly translated to the C# code if((m & 0x00800000) == 1) which only evaluates true if the expression evalaute to 1, which it never does. The correct test is to test not equal to zero (!= 0). --- Source/OpenTK/Math/Half.cs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Source/OpenTK/Math/Half.cs b/Source/OpenTK/Math/Half.cs index 3e5f4063b1..06ff241c17 100644 --- a/Source/OpenTK/Math/Half.cs +++ b/Source/OpenTK/Math/Half.cs @@ -228,7 +228,7 @@ private UInt16 SingleToHalf(Int32 si32) mantissa = mantissa + 0x00000fff + ((mantissa >> 13) & 1); - if ((mantissa & 0x00800000) == 1) + if ((mantissa & 0x00800000) != 0) { mantissa = 0; // overflow in significand, exponent += 1; // adjust exponent