- Reference >
- Operators >
- Aggregation Pipeline Operators >
- $radiansToDegrees (aggregation)
$radiansToDegrees (aggregation)¶
On this page
Definition¶
-
$radiansToDegrees¶ New in version 4.2.
Converts an input value measured in radians to degrees.
$radiansToDegreeshas the following syntax:$radiansToDegreestakes any valid expression that resolves to a number.By default
$radiansToDegreesreturns values as adouble.$radiansToDegreescan also return values as a 128-bit decimal as long as the<expression>resolves to a 128-bit decimal value.For more information on expressions, see Expressions.
Behavior¶
null, NaN, and +/- Infinity¶
If the argument resolves to a value of null or refers to a field
that is missing, $radiansToDegrees returns null. If
the argument resolves to NaN, $radiansToDegrees
returns NaN. If the argument resolves to negative or positive
infinity, $radiansToDegrees negative or positive infinity
respectively.
| Example | Results |
|---|---|
{ $radiansToDegrees: NaN } |
NaN |
{ $radiansToDegrees: null } |
null |
{ $radiansToDegrees : Infinity} |
Infinity |
{ $radiansToDegrees : -Infinity } |
-Infinity |
Example¶
The trigonometry collection contains a document that contains
three angles measured in radians:
The following aggregation operation uses the
$radiansToDegrees expression to convert each value to
its degree equivalent and add them to the input document using the
$addFields pipeline stage.
The operation returns the following document:
Since angle_a, angle_b, and angle_c are stored as
128-bit decimals, the output of
$radiansToDegrees is a 128-bit decimal.