MongoDB Query Language (MQL) Arithmetic Expression Operators
$abs
The `$abs` operator returns the absolute value of a number. It removes any negative sign from a number, making it positive.
$add
The `$add` operator adds numbers together or adds numbers and dates. When adding numbers and dates, the numbers are interpreted as milliseconds.
$ceil
The `$ceil` operator computes the ceiling of the input number. This operator returns the smallest integer value that is greater than or equal to the input.
$divide
The `$divide` operator divides two numbers and returns the quotient. The $divide operator returns an error if the divisor is zero.
$exp
The `$exp` operator returns the value of e raised to the specified exponent. The mathematical constant e is approximately equal to 2.71828.
$floor
The `$floor` operator returns the largest integer less than or equal to the specified number.
$ln
The `$ln` operator calculates the natural logarithm (base e) of the input number.
$log
The `$log` operator calculates the logarithm of a number in the specified base.
$log10
The `$log10` operator calculates the logarithm of a number in base 10 and returns the result.
$mod
The `$mod` operator returns the remainder of the division of the first number by the second.
$multiply
The `$multiply` operator calculates the product of the specified input numerical values.
$pow
The `$pow` operator calculates the value of a number raised to a specified exponent.
$round
The `$round` operator is used to round a number to a specified decimal place. It's useful in aggregations where numerical precision is important, such as financial calculations or statistical analysis.
$sqrt
The `$sqrt` operator is used to calculate the square root of a specified number.
$subtract
The `$subtract` operator is used to subtract two numbers and return the result.
$trunc
The `$trunc` operator truncates a number to a specified decimal place.