expected | The expected value. |
actual | Actual value to be compared with the expected value. |
allowedRelativeError | The relative error to be used in relative epsilon comparison. |
bool Returns true if the actual value is equaivalent to the expected value.
Relative epsilon comparison of two float values for equality.
This method does the relative epsilon comparison of two floating point numbers for equality. Supply the relative error as the third parameter. The relative error is the absolute error divided by the magnitude of the exact value.
no example available in JavaScript
using UnityEngine.TestTools.Utils;
using NUnit.Framework;
[TestFixture]
class UtilsTest { [Test]
public void FloatsAreEqual() { float expected = 10e-8f;
float actual = 0f;
float allowedRelativeError = 10e-6f;
Assert.That(Utils.AreFloatsEqual(expected, actual, allowedRelativeError), Is.True); } }