# $ZEXP

## Synopsis

$ZEXP(n)

### Parameter

Argument | Description |
---|---|

n | A number of any type. A number larger than 335.6 results in a <MAXNUMBER> error. A number smaller than -295.4 returns 0. |

## Description

$ZEXP is the exponential function en, where e is the constant 2.718281828. Therefore, to return the value of e, you can specify $ZEXP(1). $ZEXP is the inverse of the natural logarithm function $ZLN.

## Parameter

### n

Any number. It can be specified as a value, a variable, or an expression. A positive value larger than 335.6 or smaller than -4944763837 results in a <MAXNUMBER> error. A negative value smaller than -295.4 returns 0. A value of zero (0) returns 1. A non-numeric string is evaluated as 0 and therefore returns 1.

## Examples

The following example demonstrates that $ZEXP is the inverse of $ZLN:

SET x=7 WRITE $ZEXP(x),! WRITE $ZLN(x),! WRITE $ZEXP($ZLN(x))

The following example returns $ZEXP for negative and positive integers and for zero. This example returns the constant e as $ZEXP(1):

FOR x=-3:1:3 { WRITE !,"The exponential of ",x," = ",$ZEXP(x) } QUIT

returns:

The exponential of -3 = .04978706836786394297 The exponential of -2 = .1353352832366126919 The exponential of -1 = .3678794411714423216 The exponential of 0 = 1 The exponential of 1 = 2.718281828459045236 The exponential of 2 = 7.389056098930650228 The exponential of 3 = 20.08553692318766774

The following example uses IEEE floating point numbers ($DOUBLE numbers). The first $ZEXP returns a numeric value, the second $ZEXP returns “INF” (or <MAXNUMBER> depending on the IEEEError() method setting):

SET rtn=##class(%SYSTEM.Process).IEEEError(0) WRITE $ZEXP($DOUBLE(1.0E2)),! WRITE $ZEXP($DOUBLE(1.0E3))

The following example demonstrates that the empty string or a nonnumeric value is treated as 0:

WRITE $ZEXP(""),! WRITE $ZEXP("INF")

both return 1.

## See Also

$ZLN function