LOG Function | |
Calculate the natural logarithm of a numeric value.
Namespace:
XSharp.RT
Assembly:
XSharp.RT (in XSharp.RT.dll) Version: 2.21
Syntax FUNCTION LOG(
nValue AS USUAL
) AS FLOAT
public static Float LOG(
Usual nValue
)
Request Example
View SourceParameters
- 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:
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():
1? Log(10)
2? Log(10 * 2)
3? Exp(Log(1))
4? Log(2.71)
This example is a function that returns the base 10 logarithO:
1FUNCTION MyLog10(nNumber)
2 IF nNumber > 0
3 RETURN Log(nNumber)/Log(10)
4 ELSE
5 RETURN 0
6 ENDIF
See Also