Unofficial LSL Reference

[[functions:lllog]]


Unofficial LSL reference

User Tools

Login

You are currently not logged in! Enter your authentication credentials below to log in. You need to have cookies enabled to log in.

Login

Forgotten your password? Get a new one: Set new password

Function: llLog

float llLog(float arg)

Returns the natural logarithm of the argument. The natural logarithm is a logarithm in base e (the Euler constant, which is approximately 2.7182818).

Parameters

arg

The float value whose natural logarithm is to be calculated.

Return value

Returns a float which is the natural logarithm of the argument.

Notes

  • In order to make sense, the argument must be greater than 0.0; a value of 0.0 or less yields 0.0.
  • The function returns Infinity if the input is Infinity, and 0.0 if the input is -Infinity or NaN.
  • To calculate the logarithm in base 10, llLog10 can be used.
    • To calculate the logarithm in any other base, divide the result of this function by the logarithm of that base.
    • For example, to calculate the logarithm in base 2 of a number, use llLog(number)/llLog(2). Since the latter is constant, to save calculations and memory you can instead pre-calculate the reciprocal and multiply by it, like this: llLog(number)*1.44269504 will give you the logarithm in base 2, because 1/llLog(2) equals approx. 1.44269504.
  • There is no built-in inverse of this function. To raise the Euler constant to a power, use llPow. But there is also no built-in definition for the Euler constant either, so you will need to use its value, which is approx. 2.7182818.

Short examples

float f;
f = llLog(2.7182818); // sets f to 1 approx.
f = llLog(1);   // sets f to 0
f = llLog(2);   // sets f to 0.693147 approx.
f = llLog(0.5); // sets f to -0.693147 approx.
f = llLog(-1);  // sets f to 0
f = llLog(8)*1.44269504; // sets f to 3 approx.

See also

  • llLog10 to calculate the logarithm in base 10.
  • llPow to raise a number to a power (also called antilogarithm).
  • float type and associated caveats and limitations.