From 00b436a6c166d852c68bca403fd50d6bbf26d81c Mon Sep 17 00:00:00 2001 From: andf-mongodb Date: Tue, 4 May 2021 13:57:41 -0400 Subject: [PATCH] DOCS-14006 clarify return data types sum subtract --- .../reference/operator/aggregation/subtract.txt | 16 ++++++++++++++++ source/reference/operator/aggregation/sum.txt | 15 +++++++++++++++ 2 files changed, 31 insertions(+) diff --git a/source/reference/operator/aggregation/subtract.txt b/source/reference/operator/aggregation/subtract.txt index 5a5dbfc0111..49040c685d4 100644 --- a/source/reference/operator/aggregation/subtract.txt +++ b/source/reference/operator/aggregation/subtract.txt @@ -33,6 +33,22 @@ Definition first argument. For more information on expressions, see :ref:`aggregation-expressions`. +Behavior +-------- + +Starting in MongoDB 4.0.22, the result will have the same type as the +input except when it cannot be represented accurately in that type. In +these cases: + +- A 32-bit integer will be converted to a 64-bit integer if the + result is representable as a 64-bit integer. + +- A 32-bit integer will be converted to a double if the result is + not representable as a 64-bit integer. + +- A 64-bit integer will be converted to double if the result is not + representable as a 64-bit integer. + Examples -------- diff --git a/source/reference/operator/aggregation/sum.txt b/source/reference/operator/aggregation/sum.txt index 338473d858e..6d97e8d8c5c 100644 --- a/source/reference/operator/aggregation/sum.txt +++ b/source/reference/operator/aggregation/sum.txt @@ -52,6 +52,21 @@ Definition Behavior -------- +Result Data Type +~~~~~~~~~~~~~~~~ + +The result will have the same type as the input except when it cannot be +represented accurately in that type. In these cases: + +- A 32-bit integer will be converted to a 64-bit integer if the + result is representable as a 64-bit integer. + +- A 32-bit integer will be converted to a double if the result is + not representable as a 64-bit integer. + +- A 64-bit integer will be converted to double if the result is not + representable as a 64-bit integer. + Non-Numeric or Non-Existent Fields ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~