| Parameter | Description |
|---|---|
| f | Base of the exponentiation operation. |
| p | Exponent of the exponentiation operation. |
float Result of the exponentiation operation.
Returns the result of raising f to the power p.
The behaviour of exponentiation varies greatly depending on the sign and range of the exponent p:
f by itself p times.f, with n being 1/p.f to the absolute (non-signed) value of p.Additional resources: Log.
using UnityEngine;
public class Example : MonoBehaviour { void Start() { // Prints Infinity Debug.Log(Mathf.Pow(2, Mathf.Infinity)); // Prints 256 Debug.Log(Mathf.Pow(2, 8)); // Prints 2 Debug.Log(Mathf.Pow(2, 1)); // Prints 1.414214 Debug.Log(Mathf.Pow(2, 0.5f)); // Prints 1 Debug.Log(Mathf.Pow(2, 0)); // Prints 0.7071068 Debug.Log(Mathf.Pow(2, -0.5f)); // Prints 0.5 Debug.Log(Mathf.Pow(2, -1)); // Prints 0.00390625 Debug.Log(Mathf.Pow(2, -8)); // Prints 0 Debug.Log(Mathf.Pow(2, -Mathf.Infinity)); } }