Click or drag to resize

LOG Function

Calculate the natural logarithm of a numeric value.

Namespace:  XSharp.RT
Assembly:  XSharp.RT (in XSharp.RT.dll) Version: 2.08
Syntax
 FUNCTION LOG(
	nValue AS USUAL
) AS FLOAT
View Source

Parameters

nValue
Type: Usual
A number greater than 0 to convert to its natural logarithm.

Return Value

Type: Float
The natural logarithm of <nValue>.  If <nValue> is less than or equal to 0, Log() generates a numeric overflow.
Remarks
The Log() function returns x in the following equation:
X#
e^x = y
where e is the base of the natural logarithm (approximately 2.7183) and y is the numeric expression used as the Log() argument (that is, Log(y) = x).  Due to mathematical rounding, the values returned by Log() and Exp() may not agree exactly (that is, Exp(Log(n)) may not always equal n). Log() is the inverse of Exp().
Examples
These examples demonstrate various results of Log():
X#
? Log(10)                                        // 2.30
? Log(10 * 2)                                // 3.00
? Exp(Log(1))                                // 1.00
? Log(2.71)                                        // 1.00
This example is a function that returns the base 10 logarithm:
X#
FUNCTION MyLog10(nNumber)
        IF nNumber > 0
                RETURN Log(nNumber)/Log(10)
        ELSE
                RETURN 0
        ENDIF
See Also