﻿LOG Function

# LOG Function

Calculate the natural logarithm of a numeric value.

Namespace:  XSharp.RT
Assembly:  XSharp.RT (in XSharp.RT.dll) Version: 2.7
Syntax
``` FUNCTION LOG(
nValue AS USUAL
) AS FLOAT```

#### 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#
`1e^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#
```1? Log(10)                    // 2.30
2? Log(10 * 2)                // 3.00
3? Exp(Log(1))                // 1.00
4? Log(2.71)                    // 1.00```
This example is a function that returns the base 10 logarithO:
X#
```1FUNCTION MyLog10(nNumber)
2    IF nNumber > 0
3        RETURN Log(nNumber)/Log(10)
4    ELSE
5        RETURN 0
6    ENDIF```