Upravit

Sdílet prostřednictvím


FloatingPointNumerics.AreAlmostEqualUlps Method

Definition

Overloads

AreAlmostEqualUlps(Double, Double, Int64)

Compares two double precision floating point values for equality

AreAlmostEqualUlps(Single, Single, Int32)

Compares two floating point values for equality

AreAlmostEqualUlps(Double, Double, Int64)

Compares two double precision floating point values for equality

public static bool AreAlmostEqualUlps (double left, double right, long maxUlps);
static member AreAlmostEqualUlps : double * double * int64 -> bool

Parameters

left
Double

First double precision floating point value to be compared

right
Double

Second double precision floating point value t be compared

maxUlps
Int64

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.

Applies to

AreAlmostEqualUlps(Single, Single, Int32)

Compares two floating point values for equality

public static bool AreAlmostEqualUlps (float left, float right, int maxUlps);
static member AreAlmostEqualUlps : single * single * int -> bool

Parameters

left
Single

First floating point value to be compared

right
Single

Second floating point value t be compared

maxUlps
Int32

Maximum number of representable floating point values that are allowed to be between the left and the right floating point values

Returns

True if both numbers are equal or close to being equal

Remarks

Floating point values can only represent a finite subset of natural numbers. For example, the values 2.00000000 and 2.00000024 can be stored in a float, but nothing inbetween them.

This comparison will count how many possible 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.

Applies to