Function Log() Foundation

Calculates the natural logarithm of a numeric value.

Syntax
Log( <nExpression> ) --> nNaturalLog
Parameters
<nExpression>
<nExpression> is a numeric expression greater than zero whose natural logarithm is calculated.
Return

Log() returns the natural logarithm of a numeric value. When <nExpression> is less than or equal to zero, a numeric overflow occurs and "*****" is displayed.

Description

Log() is a mathematical function which calculates the natural logarithm of a numeric value. Log() is the reverse of the function Exp(). Because of rounding errors the results of Log() and Exp() can deviate from one another, and the expression Exp(Log(nValue)) can differ from the value nValue.

The number of decimal places in the display of the result depends only on SET DECIMALS and not on the current setting of SET FIXED.

Examples
Log()
// The example shows various results of the function Log() 

PROCEDURE Main 

   ? Log(10)                 // result: 2.30 
   ? Log(100)                // result: 4.61 
   ? Exp(Log(1))             // result: 1.00 
   ? Log(2.718281828)        // result: 1.00 

RETURN 
Calculate decimal logarithm

// The function Log10 calculates the decimal (base 10) 
// logarithm of a numeric value. 

FUNCTION Log10( nValue ) 
   IF nValue > 0 
      nValue := Log( nValue ) / Log( 10 ) 
   ELSE 
      nValue := NIL 
   ENDIF 

RETURN nValue 

Feedback

If you see anything in the documentation that is not correct, does not match your experience with the particular feature or requires further clarification, please use this form to report a documentation issue.