- Reference >
- Operators >
- Aggregation Pipeline Operators >
- $exp (aggregation)
$exp (aggregation)¶
On this page
Definition¶
-
$exp
¶ New in version 3.2.
Raises Euler’s number (i.e. e ) to the specified exponent and returns the result.
$exp
has the following syntax:The
<exponent>
expression can be any valid expression as long as it resolves to a number. For more information on expressions, see Expressions.
Behavior¶
If the argument resolves to a value of null
or refers to a field that is
missing, $exp
returns null
. If the argument resolves to
NaN
, $exp
returns NaN
.
Example | Results |
---|---|
{ $exp: 0 } |
1 |
{ $exp: 2 } |
7.38905609893065 |
{ $exp: -2 } |
0.1353352832366127 |
Example¶
A collection named accounts
contains the following documents:
The following example calculates the effective interest rate for continuous compounding:
The operation returns the following results: