NUnit.Framework.Constraints.FloatingPointNumerics.AreAlmostEqualUlps Method
Compares two double precision floating point values for equality

Syntax

public static bool AreAlmostEqualUlps (double left, double right, long maxUlps)

Parameters

left
First double precision floating point value to be compared
right
Second double precision floating point value t be compared
maxUlps
Maximum number of representable double precision floating point values that are allowed to be between the left and the right double precision floating point values

Returns

True if both numbers are equal or close to being equal

Remarks

Double precision floating point values can only represent a limited series of natural numbers. For example, the values 2.0000000000000000 and 2.0000000000000004 can be stored in a double, but nothing inbetween them.

This comparison will count how many possible double precision floating point values are between the left and the right number. If the number of possible values between both numbers is less than or equal to maxUlps, then the numbers are considered as being equal.

Implementation partially follows the code outlined here: http://www.anttirt.net/2007/08/19/proper-floating-point-comparisons/

Requirements

Namespace: NUnit.Framework.Constraints
Assembly: NUnitLite (in NUnitLite.dll)
Assembly Versions: 0.6.0.0, 1.0.0.0