{!See https://docs.google.com/document/d/1takg_GmIBBKKTj-GHZCwzxohpQz7Bhekivkk72kYMtE/edit for reference implementation of OneTrust, dataLayer and GTM} {!OneTrust Cookies Consent} {!OneTrust Cookies Consent end} {!dataLayer initialization push} {!dataLayer initialization push end} {!Google Tag Manager} {!Google Tag Manager end} Method AreFloatsEqualAbsoluteError | Test Framework | 2.0.1-exp.2
docs.unity3d.com
Search Results for

    Show / Hide Table of Contents

    Method AreFloatsEqualAbsoluteError

    AreFloatsEqualAbsoluteError(float, float, float)

    Compares two floating point numbers for equality under the given absolute tolerance.

    Declaration
    public static bool AreFloatsEqualAbsoluteError(float expected, float actual, float allowedAbsoluteError)
    Parameters
    Type Name Description
    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.

    Returns
    Type Description
    bool

    Returns true if the actual value is equivalent to the expected value under the given tolerance.

    Examples
    [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);
        }
    }
    In This Article
    Back to top
    Copyright © 2023 Unity Technologies — Trademarks and terms of use
    • Legal
    • Privacy Policy
    • Cookie Policy
    • Do Not Sell or Share My Personal Information
    • Your Privacy Choices (Cookie Settings)