Skip to main content

$round

The $round operator rounds the first number to the specified number of decimal places.

Input

  • An array containing exactly two numeric values: the number to round and the number of decimal places

Output

  • The first value rounded to the specified number of decimal places

Examples

Round to Integer

{
  "$round": [
    3.7,
    0
  ]
}
Result: 4

Round to One Decimal Place

{
  "$round": [
    3.14159,
    2
  ]
}
Result: 3.14

Round to Two Decimal Places

{
  "$round": [
    123.456789,
    2
  ]
}
Result: 123.46

Field Value

{
  "$round": [
    {
      "$input": "price"
    },
    2
  ]
}
Result: The price field rounded to 2 decimal places