Legacy Documentation: Version 5.1
LanguageEnglish
  • C#
  • JS

Script language

Select your preferred scripting language. All code snippets will be displayed in this language.

Assert.AreApproximatelyEqual

Switch to Manual
public static function AreApproximatelyEqual(expected: float, actual: float): void;
public static function AreApproximatelyEqual(expected: float, actual: float, message: string): void;
public static function AreApproximatelyEqual(expected: float, actual: float, tolerance: float): void;
public static function AreApproximatelyEqual(expected: float, actual: float, tolerance: float, message: string): void;

Parameters

tolerance Tolerance of approximation.

Description

Asserts that the values are approximately equal. An absolute error check is used for approximate equality check (|a-b| < tolerance). Default tolerance is 0.00001f.

Note: Every time you call the method with tolerance specified, a new instance of FloatComparer is created. For performance reasons you might want to instance your own comparer and pass it to the AreEqual method. If the tolerance is not specifies, a default comparer is used and the issue does not occur.