CSharpImageLibrary.DDS.DDS_BlockHelpers.GetClosestValue C# (CSharp) Method

GetClosestValue() private static method

private static GetClosestValue ( byte arr, byte c ) : int
arr byte
c byte
return int
        private static int GetClosestValue(byte[] arr, byte c)
        {
            int min = int.MaxValue;
            int index = 0;
            int minIndex = 0;
            for (int i = 0; i < arr.Length; i++)
            {
                int check = arr[i] - c;
                check = (check ^ (check >> 7)) - (check >> 7);
                if (check < min)
                {
                    min = check;
                    minIndex = index;
                }

                index++;
            }
            return minIndex;
        }