Skip to content

llLog

float llLog(float Value)

Returns the natural logarithm of Value. Returns zero if Value <= 0.

Returns the base e (natural) logarithm of the specified Value.

Parameters
Value (float)

Basic usage to calculate natural logarithm:

default
{
state_entry()
{
float num1 = llFrand(100.0);
llOwnerSay("The natural logarithm of " + (string)num1 + " is " + (string)llLog(num1));
}
}

Converting to arbitrary logarithm base:

float findexp(float result, float base)
{
return llLog(result)/llLog(base);
}
default
{
touch_start(integer total_number)
{
llSay(0, (string)findexp(8.0, 2.0));
// returns 3.0
}
}

There are only two logarithm functions: llLog and llLog10. When converting the base of the logarithm, use llLog rather than llLog10 as it introduces fewer errors. The general formula for converting to an arbitrary base is:

float LogBaseN = llLog(value) / llLog(Base);

Note that this technique inherently introduces errors due to floating-point arithmetic, which are most noticeable when working with logarithms. If the base is a constant, your script will run faster if you pre-calculate its logarithm and divide by that constant instead.

Numberln(Number)
20.693147
41.386294
82.079442
102.302585
162.772589
323.465736
644.158883
1284.852030
2565.545177