Documentation index for AI agents (llms.txt) A Markdown version of every page is available: request the page's source under /docs/, follow the "alternate" link in this page's head, or start from /llms.txt.
Visual Script logo Manual

Approximately#

Math / Numbers / Approximately

  • Can Read

  • Cannot Write

Description#

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

Code#

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;
    }
}
Visual Script logoVisual Script © Catsoft Works 2026. All rights reserved.