# MustBeApproximatelyEqual

> An extension method for Assert.AreApproximatelyEqual.

## Definition

* **Type:** Method
* **Namespace:** [UnityEngine.Assertions.Must](/engine/6000.6/script-reference/unityengine/assertions/must.md)
* **Assembly:** UnityEngine.CoreModule

## MustBeApproximatelyEqual(float, float)

An extension method for [Assert.AreApproximatelyEqual](/engine/6000.6/script-reference/unityengine/assertions/assert/areapproximatelyequal.md).

> **Warning:**
>
> **Deprecated.** Must extensions are deprecated. Use UnityEngine.Assertions.Assert instead

```csharp
[Conditional("UNITY_ASSERTIONS")]
public static void MustBeApproximatelyEqual(this float actual, float expected)
```

### Parameters

**** (\[float]\(https\://learn.microsoft.com/dotnet/api/system.single)): **** (\[float]\(https\://learn.microsoft.com/dotnet/api/system.single)):&#x20;

### Examples

```csharp
using UnityEngine;
using UnityEngine.Assertions;
using UnityEngine.Assertions.Must;

public class AssertionExampleClass : MonoBehaviour
{
    void Update()
    {
        //Make sure the position of the GameObject is always in the center of the Scene.
        //MustBeApproximatelyEqual should be used for comparing floating point variables.
        //Unless specified, default error tolerance will be used.
        transform.position.x.MustBeApproximatelyEqual(0.0f);
        transform.position.y.MustBeApproximatelyEqual(0.0f);
        transform.position.z.MustBeApproximatelyEqual(0.0f);
    }
}
```

## MustBeApproximatelyEqual(float, float, string)

An extension method for [Assert.AreApproximatelyEqual](/engine/6000.6/script-reference/unityengine/assertions/assert/areapproximatelyequal.md).

> **Warning:**
>
> **Deprecated.** Must extensions are deprecated. Use UnityEngine.Assertions.Assert instead

```csharp
[Conditional("UNITY_ASSERTIONS")]
public static void MustBeApproximatelyEqual(this float actual, float expected, string message)
```

### Parameters

**** (\[float]\(https\://learn.microsoft.com/dotnet/api/system.single)): **** (\[float]\(https\://learn.microsoft.com/dotnet/api/system.single)): **** (\[string]\(https\://learn.microsoft.com/dotnet/api/system.string)):&#x20;

### Examples

```csharp
using UnityEngine;
using UnityEngine.Assertions;
using UnityEngine.Assertions.Must;

public class AssertionExampleClass : MonoBehaviour
{
    void Update()
    {
        //Make sure the position of the GameObject is always in the center of the Scene.
        //MustBeApproximatelyEqual should be used for comparing floating point variables.
        //Unless specified, default error tolerance will be used.
        transform.position.x.MustBeApproximatelyEqual(0.0f);
        transform.position.y.MustBeApproximatelyEqual(0.0f);
        transform.position.z.MustBeApproximatelyEqual(0.0f);
    }
}
```

## MustBeApproximatelyEqual(float, float, float)

An extension method for [Assert.AreApproximatelyEqual](/engine/6000.6/script-reference/unityengine/assertions/assert/areapproximatelyequal.md).

> **Warning:**
>
> **Deprecated.** Must extensions are deprecated. Use UnityEngine.Assertions.Assert instead

```csharp
[Conditional("UNITY_ASSERTIONS")]
public static void MustBeApproximatelyEqual(this float actual, float expected, float tolerance)
```

### Parameters

**** (\[float]\(https\://learn.microsoft.com/dotnet/api/system.single)): **** (\[float]\(https\://learn.microsoft.com/dotnet/api/system.single)): **** (\[float]\(https\://learn.microsoft.com/dotnet/api/system.single)):&#x20;

### Examples

```csharp
using UnityEngine;
using UnityEngine.Assertions;
using UnityEngine.Assertions.Must;

public class AssertionExampleClass : MonoBehaviour
{
    void Update()
    {
        //Make sure the position of the GameObject is always in the center of the Scene.
        //MustBeApproximatelyEqual should be used for comparing floating point variables.
        //Unless specified, default error tolerance will be used.
        transform.position.x.MustBeApproximatelyEqual(0.0f);
        transform.position.y.MustBeApproximatelyEqual(0.0f);
        transform.position.z.MustBeApproximatelyEqual(0.0f);
    }
}
```

## MustBeApproximatelyEqual(float, float, float, string)

An extension method for [Assert.AreApproximatelyEqual](/engine/6000.6/script-reference/unityengine/assertions/assert/areapproximatelyequal.md).

> **Warning:**
>
> **Deprecated.** Must extensions are deprecated. Use UnityEngine.Assertions.Assert instead

```csharp
[Conditional("UNITY_ASSERTIONS")]
public static void MustBeApproximatelyEqual(this float actual, float expected, float tolerance, string message)
```

### Parameters

**** (\[float]\(https\://learn.microsoft.com/dotnet/api/system.single)): **** (\[float]\(https\://learn.microsoft.com/dotnet/api/system.single)): **** (\[float]\(https\://learn.microsoft.com/dotnet/api/system.single)): **** (\[string]\(https\://learn.microsoft.com/dotnet/api/system.string)):&#x20;

### Examples

```csharp
using UnityEngine;
using UnityEngine.Assertions;
using UnityEngine.Assertions.Must;

public class AssertionExampleClass : MonoBehaviour
{
    void Update()
    {
        //Make sure the position of the GameObject is always in the center of the Scene.
        //MustBeApproximatelyEqual should be used for comparing floating point variables.
        //Unless specified, default error tolerance will be used.
        transform.position.x.MustBeApproximatelyEqual(0.0f);
        transform.position.y.MustBeApproximatelyEqual(0.0f);
        transform.position.z.MustBeApproximatelyEqual(0.0f);
    }
}
```
