InterSystems IRIS Data Platform 2019.2  /  ObjectScript Reference  /  ObjectScript Functions

ObjectScript Reference
Previous section           Next section
InterSystems: The power behind what matters   

Exponential function (inverse of natural logarithm).
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.
$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.
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.
The following example demonstrates that $ZEXP is the inverse of $ZLN:
  SET x=7
  WRITE $ZEXP(x),!
  WRITE $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) 
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)),!
The following example demonstrates that the empty string or a nonnumeric value is treated as 0:
   WRITE $ZEXP(""),!
both return 1.
See Also

Previous section           Next section
Send us comments on this page
View this book as PDF   |  Download all PDFs
Copyright © 1997-2019 InterSystems Corporation, Cambridge, MA
Content Date/Time: 2019-09-20 05:47:55