exp

operator

Library: Floating point number support (OMFLOAT)
Import : omfloat.xmd
Library: Binary coded decimal numbers (OMBCD)
Import : ombcd.xmd

Returns: e raised to the power of x.


Declaration
define overloaded external float function
    exp value float x

define overloaded external bcd function
    exp value bcd x

Argument definitions

x
a floating point number
x
a BCD number


Purpose

Use exp to calculate the value of e raised to the power of either a floating point number or a BCD number.

Requirements

To use ombcd or omfloat, you must import the module into your program using a statement like one of these two:

(Please see the import topic for more on importing.)

Usage Notes

e is Euler's number, and is approximately equal to 2.71828182845904523536028747135 ...

You use BCD mathematics typically for financial calculations and floating point mathematics typically for extremely large numbers.

You calculate the value of e raised to the argument of exp, as in

  set my-value to exp (x)

If the result of an exponential value does not fit in the data type of the argument, the value returned is truncated to fit the data type.

If you take the exponential value 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 exponential function is called.

In OmniMark, always surround operators with spaces.

BCD Example:


  ; Displays e to the power of 2 as a BCD
  import "ombcd.xmd" unprefixed
  process
    local bcd x initial {"2.3025850929940461"}
    local bcd result
  
    set result to exp (x)
    output "e to the power of " || "d" % x || " = " || "d" % result || "%n"
  ; Output: "e to the power of 2.3025850929940461 = 10.0000000000000002"

Floating Point Example:


  ; Displays the value of e to the power of 2 as a floating point number.
  import "omfloat.xmd" unprefixed
  process
    local float x initial {"2.3025850929940461"}
    local float result
  
    set result to exp (x)
    output "e to the power of " || "d" % x || " = " || "d" % result || "%n"
  ; Output: "e to the power of 2.3025850929940461 = 10"

In the example above, instead of using the line set result to exp (x), you could have written set result to e ** x.

Related Topics
Other Library Functions