- Reference >
- Operators >
- Aggregation Pipeline Operators >
- $ln (aggregation)
$ln (aggregation)¶
On this page
Definition¶
-
$ln
¶ New in version 3.2.
Calculates the natural logarithm ln (i.e loge) of a number and returns the result as a double.
$ln
has the following syntax:The
<number>
expression can be any valid expression as long as it resolves to a non-negative number. For more information on expressions, see Expressions.$ln
is equivalent to$log: [ <number>, Math.E ]
expression, whereMath.E
is a JavaScript representation for Euler’s number e.
Behavior¶
If the argument resolves to a value of null
or refers to a field that is
missing, $ln
returns null
. If the argument resolves to
NaN
, $ln
returns NaN
.
Example | Results |
---|---|
{ $ln: 1 } |
0 |
{ $ln: Math.E } where Math.E is a JavaScript representation for e. |
1 |
{ $ln: 10 } |
2.302585092994046 |