Unity - Scripting API: Mathf.Log
Success!
Thank you for helping us improve the quality of Unity Documentation. Although we cannot accept all submissions, we do read each suggested change from our users and will make updates where applicable.
Submission failed
For some reason your suggested change could not be submitted. Please <a>try again</a> in a few minutes. And thank you for taking the time to help us improve the quality of Unity Documentation.
Declaration
public static float Log(float f, float p);
Parameters
| Parameter | Description |
|---|---|
| f | Value to compute the logarithm for. |
| p | Base of the logarithm operation. |
Returns
float Result of the logarithm operation.
Description
Returns the logarithm of a specified number in a specified base.
The logarithm is the inverse function of exponentiation, meaning that it will output the exponent to which p needs to be raised to obtain f.
This function will return NaN if either:
- The value of f is negative.
- The value of p is negative, 0, 1 or Infinity.
Additionally, when the above is true, this function will return ±Infinity when:
- f equals Infinity (will return +Infinity).
- f equals 0 (-Infinity when p is in the (1,∞] range, +Infinity when p is in the (0,1) range).
Additional resources: Pow.
Declaration
public static float Log(float f);
Parameters
| Parameter | Description |
|---|---|
| f | Value to compute the logarithm for. |
Returns
float Result of the logarithm operation.
Description
Returns the natural (base e) logarithm of a specified number.
Computing the natural logarithm of f is the inverse operation to computing the Exponential of the output of this function. This means that 'Mathf.Exp(x) = f', with x being the output of this function.
Additional resources: Exp.