swirl Guide to OmniMark 5   OmniMark home
docs home 
IndexConceptsTasksSyntaxLibrariesOMX VariablesErrors
 
  Related Syntax    
operator   ln    

Return type: Opaque
Returns:       

The natural logarithm of a floating point or bcd number if greater than zero. The argument must be greater than zero.



Syntax
  define external float function
      ln value float x

  define external bcd function
      ln value bcd x


Purpose

Use ln to calculate the natural logarithm (logarithm to the base e), of either

You must include either omfloat.xin or ombcd.xin in your program. Decide whether you want BCD mathematics (excellent for financial calculations) or floating point mathematics (excellent for extremely large numbers).

Floating Point Example:

  ; Displays the natural logarithm of 10  as a floating point number.
  include "omfloat.xin"
  process
    local float x-var initial {"10"}
    local float result

    set result to ln (x-var)
    output "Natural logarithm of " || "d" % x-var || " = " || "d" % result || "%n"
  ; Output: "Natural logarithm of 10 = 2.302585092994046".

BCD Example:

  ; Multiply x and y by adding their natural logarithms.
  ; In this case, display the product obtained by adding the natural logarithms of 100 and 50.
  include "ombcd.xin"
  process
     local bcd  x initial {"100"}
     local bcd  y initial {"50"}
     local bcd lnx
     local bcd lny
     local bcd product-from-ln

     set lnx to ln (x)
     set lny to ln (y)
     set product-from-ln to exp(lnx + lny)
     output "Product of 100 times 50 from adding natural logarithms = "
         || "d" % product-from-ln
         || "%n"
  ; Output: "Product of 100 times 50 from adding natural logarithms = 4999.9999999999967158" 

If the result of a natural logarithm does not fit in the data type of the argument, the value returned is truncated to fit the data type.

If you calculate the natural logarithm of an integer, the result is coerced into the data type of the library you have included - either a floating point or BCD number.

In an OmniMark program, always surround operators with spaces.

    Related Syntax
   sqrt
   exp
   log10
   **
 
 
----  

Top [ INDEX ] [ CONCEPTS ] [ TASKS ] [ SYNTAX ] [ LIBRARIES ] [ OMX ] [ OMX ] [ ERRORS ]

Generated: August 11, 2000 at 3:07:29 pm
If you have any comments about this section of the documentation, send email to docerrors@omnimark.com

Copyright © OmniMark Technologies Corporation, 1988-2000.