Sign(float)
Returns the mathematical sign of f.
Read time 1 minuteLast updated 6 days ago
Definition
- Type: Method
- Namespace: UnityEngine
- Assembly: UnityEngine.CoreModule
public static float Sign(float f)
Parameters
Real number whose sign will be retrieved.
Returns
Type | Description |
|---|---|
| float | Mathematical sign of |
Remarks
Returns either a value of -1 when is negative, or a value of 1 when is 0 or greater. This is different from standard 'Sign' implementations which return 0 whenever equals 0.
fffExamples
using UnityEngine;public class Example : MonoBehaviour{ void Start() { // Prints -1 Debug.Log(Mathf.Sign(-10)); // Prints 1 Debug.Log(Mathf.Sign(0)); // Prints 1 Debug.Log(Mathf.Sign(10)); }}