All pastes #292416 Raw Edit

Stuff

public text v1 · immutable
#292416 ·published 2006-12-26 14:18 UTC
rendered paste body
            float epsilon = 1 / 100000.0f;

            // If both numbers are NaN, return true
            if (value1.Equals(float.NaN) && value2.Equals(float.NaN))
                return true;

            // If both are positive or both are negative
            if (Math.Sign(value1) == Math.Sign(value2))
                return (Math.Abs(Math.Abs(value1) - Math.Abs(value2)) < epsilon);


            // If one is positive and one is negative we need to be careful
            return ((Math.Abs(value1) + Math.Abs(value2)) < epsilon);