---
tags:
    - "Positive"
    - "Negative"
    - "Symbol"
---

# Sign

[Math](../index.md) / [Arithmetic](index.md) / **Sign**

<div class="grid cards" markdown>

* :green_circle: Can Read

* :red_circle: Cannot Write

</div>

## Description

Returns +1 if the value is zero or positive and returns -1 otherwise

## Code

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

namespace VisualScript.Runtime
{
    [Get]
    
    [Title("Sign")]
    [Category("Math/Arithmetic/Sign")]
    
    [Description("Returns +1 if the value is zero or positive and returns -1 otherwise")]
    [Image(typeof(IconSign), ColorTheme.Type.Yellow)]
    
    [Keywords("Positive", "Negative", "Symbol")]
    
    [Serializable]
    public class TypeNumberMathSign : TypeNumber
    {
        [SerializeField] private GetNumber m_Number = new GetNumber();

        public override double GetPreview(GameObject source) => Math.Sign(this.m_Number.GetPreview(source));

        public override double Get(Args args)
        {
            double number = this.m_Number.Get(args);
            return Math.Sign(number);
        }

        public override string ToString()
        {
            return $"Sign({this.m_Number})";
        }
        
        protected override SubscriptionMode Subscription => SubscriptionMode.OnChange;
    }
}
```

