Returns the absolute value of f.
using UnityEngine;
public class ScriptExample : MonoBehaviour { void Start() { // Prints 10 Debug.Log(Mathf.Abs(-10.0f)); // Prints 0 Debug.Log(Mathf.Abs(0.0f)); // Prints 10 Debug.Log(Mathf.Abs(10.0f)); } }
| Parameter | Description |
|---|---|
| value | Integer number whose absolute value will be returned. |
int
Non-negative value of value.
Returns the absolute value of value.
For an integer number value, its absolute value is defined as its non-negative value without regard to its sign.
Additional resources: Sign.