- Reference >
- Operators >
- Aggregation Pipeline Operators >
- Arithmetic Aggregation Operators >
- $log10 (aggregation)
$log10 (aggregation)¶
On this page
Definition¶
-
$log10¶ New in version 3.2.
Calculates the log base 10 of a number and returns the result as a double.
$log10has 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.$log10is equivalent to$log: [ <number>, 10 ]expression.
Behavior¶
If the argument resolves to a value of null or refers to a field that is
missing, $log10 returns null. If the argument resolves to
NaN, $log10 returns NaN.
| Example | Results |
|---|---|
{ $log10: 1 } |
0 |
{ $log10: 10 } |
1 |
{ $log10: 100 } |
2 |
{ $log10: 1000 } |
3 |