Parameter | Description |
---|---|
f | Real number whose absolute value will be returned. |
float
Non-negative value of f
.
Returns the absolute value of f
.
For a real number f
, its absolute value is defined as the non-negative value of f
without regard to its sign.
Additional resources: Sign.
using UnityEngine;
public class Example : MonoBehaviour { void Start() { // Prints 10 Debug.Log(Mathf.Sign(-10.0f)); // Prints 0 Debug.Log(Mathf.Sign(0.0f)); // Prints 10 Debug.Log(Mathf.Sign(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.
using UnityEngine;
public class Example : MonoBehaviour { void Start() { // Prints 10 Debug.Log(Mathf.Sign(-10)); // Prints 0 Debug.Log(Mathf.Sign(0)); // Prints 10 Debug.Log(Mathf.Sign(10)); } }