MongoDB Query Language (MQL) Arithmetic Expression Operators
Arithmetic expression operators perform mathematical calculations on numeric values in your documents. These operators support standard mathematical operations such as absolute value, exponentiation, rounding, and other numeric computations within aggregation pipelines and queries.
$abs
The $abs operator returns the absolute value of a number.
$add
The $add operator returns the sum of two numbers or the sum of a date and numbers.
$ceil
The $ceil operator returns the smallest integer greater than or equal to the specified number.
$divide
The $divide operator divides two numbers and returns the quotient.
$exp
The $exp operator raises e to the specified exponent and returns the result
$floor
The $floor operator returns the largest integer less than or equal to the specified number
$ln
The $ln operator calculates the natural logarithm of the input
$log
The $log operator calculates the logarithm of a number in the specified base
$log10
The $log10 operator calculates the log of a specified number in base 10
$multiply
The $multiply operator multiplies the input numerical values
$pow
The `$pow` operator calculates the value of a numerical value raised to the power of a specified exponent.
$round
The $round operator rounds a number to a specified decimal place.
$sqrt
The $sqrt operator calculates and returns the square root of an input number
$subtract
The $subtract operator subtracts two numbers and returns the result.
$trunc
The $trunc operator truncates a number to a specified decimal place.