Method AreFloatsEqualAbsoluteError
AreFloatsEqualAbsoluteError(float, float, float)
Compares two floating point numbers for equality under the given absolute tolerance.
선언
public static bool AreFloatsEqualAbsoluteError(float expected, float actual, float allowedAbsoluteError)
파라미터
타입 | 이름 | 설명 |
---|---|---|
float | expected | The expected float value used to compare. |
float | actual | The actual float value to test. |
float | allowedAbsoluteError | AllowedAbsoluteError is the permitted error tolerance. |
반환
타입 | 설명 |
---|---|
bool | Returns true if the actual value is equivalent to the expected value under the given tolerance. |
예
[TestFixture]
class UtilsTests
{
[Test]
public void CheckThat_FloatsAreAbsoluteEqual()
{
float expected = 0f;
float actual = 10e-6f;
float error = 10e-5f;
Assert.That(Utils.AreFloatsEqualAbsoluteError(expected, actual, error), Is.True);
}
}