---
tags:
    - "Same"
    - "Compare"
    - "Equal"
    - "Exact"
    - "Similar"
    - "="
---

# Approximately

[Math](../index.md) / [Numbers](index.md) / **Approximately**

<div class="grid cards" markdown>

* :green_circle: Can Read

* :red_circle: Cannot Write

</div>

## Description

Returns whether two decimal values are (almost) equal to each other

## Code

```cs
using System;
using UnityEngine;
using VisualScript.Icons;

namespace VisualScript.Runtime
{
    [Get]
    
    [Title("Approximately")]
    [Category("Math/Numbers/Approximately")]
    
    [Description("Returns whether two decimal values are (almost) equal to each other")]
    [Image(typeof(IconEqualsCircle), ColorTheme.Type.Yellow)]
    
    [Keywords("Same", "Compare", "Equal", "Exact", "Similar", "=")]
    
    [Serializable]
    public class TypeBoolMathNumbersApproximately : TypeBool
    {
        private const double Epsilon = float.Epsilon;
        
        [SerializeField] private GetNumber m_Number1 = new GetNumber();
        [SerializeField] private GetNumber m_Number2 = new GetNumber();

        public override bool GetPreview(GameObject source)
        {
            double number1 = this.m_Number1.GetPreview(source);
            double number2 = this.m_Number2.GetPreview(source);

            return Math.Abs(number1 - number2) < Epsilon;
        }

        public override bool Get(Args args)
        {
            double number1 = this.m_Number1.Get(args);
            double number2 = this.m_Number2.Get(args);
            
            return Math.Abs(number1 - number2) < Epsilon;
        }

        public override string ToString()
        {
            return $"{this.m_Number1} = {this.m_Number2}";
        }

        protected override SubscriptionMode Subscription => SubscriptionMode.OnChange;
    }
}
```

