swirl
Guide to OmniMark 7   OmniMark home
docs home 
IndexConceptsTasksSyntaxLibrariesLegacy LibrariesErrors
 
  Related Syntax    
operator  

ln

 

 

Return type: OMX
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 import either omfloat.xmd or ombcd.xmd 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.
  import "omfloat.xmd" unprefixed
  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.
  import "ombcd.xmd" unprefixed
  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, you need to coerce the integer - to a floating point or BCD number - so that the appropriate function is called. The result will depend on which logarithm function is called.

In an OmniMark program, always surround operators with spaces.

    Related Syntax
   sqrt
   exp
   log10
   ** (power)
 
 
 

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

OmniMark 7.1.2 Documentation Generated: June 28, 2005 at 5:45:28 pm
If you have any comments about this section of the documentation, send email to [email protected]

Copyright © Stilo Corporation, 1988-2005.