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

Return type: Opaque
Returns:       

The logarithm base ten for a bcd or a floating point number. The value of x must be greater than 0.



Syntax
  define external float function
      log10 value float x

  define external bcd function
      log10 value bcd x


Purpose

Use log10 to calculate the logarithm base ten of:

You must include either ombcd.xin or omfloat.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 base-10 logarithm of 100  as a floating point number.
  include "omfloat.xin"
  process
      local float x initial {"100"}
      local float result

      set result to log10 (x)
      output "Logarithm (base 10) of " || "d" % x || " = " || "d" % result || "%n"
  ; Output: "Logarithm (base 10) of 100 = 2".

BCD Example:

  ;  How to multiply BCD numbers by adding their base 10 logarithms.
  include "ombcd.xin"
    process
      local bcd x-var initial {"100"}
      local bcd y-var initial {"50"}
      local bcd log10-x
      local bcd log10-y
      local bcd x-times-y
      local bcd logarithm-total

      set log10-x to log10 (x-var)
      output "Logarithm (base 10) of " || "d" % x-var || " = " || "d" % log10-x || "%n"
  ;   Output: "Logarithm (base 10) of 100 = 2".

      set log10-y to log10 (y-var)
      output "Logarithm (base 10) of " || "d" % y-var || " = " || "d" % log10-y || "%n"
  ;   Output: "Logarithm (base 10) of 50 = 1.6989700043360182".

      set logarithm-total to log10-x + log10-y
      set x-times-y to 10 ** logarithm-total
      output "100 times 50 by adding logarithms = " || "d" % x-times-y  || "%n"
  ;   Output: "100 times 50 by adding logarithms = 4999.999999999992".

If the result of a logarithm (base 10) 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 OmniMark, always surround operators with spaces.

    Related Syntax
   sqrt
   exp
   ln
   **
 
 
----  

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

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

Copyright © OmniMark Technologies Corporation, 1988-2000.