This is an automated email from the ASF dual-hosted git repository.
victoria pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/druid.git
The following commit(s) were added to refs/heads/master by this push:
new 65a663adbb docs: clarify Java precision (#13671)
65a663adbb is described below
commit 65a663adbb8f1fd39c3bcc029a96f5a650a6928d
Author: 317brian <[email protected]>
AuthorDate: Wed Mar 15 11:43:41 2023 -0700
docs: clarify Java precision (#13671)
Co-authored-by: Katya Macedo <[email protected]>
Co-authored-by: Victoria Lim <[email protected]>
---
docs/querying/sql-operators.md | 7 +++++++
1 file changed, 7 insertions(+)
diff --git a/docs/querying/sql-operators.md b/docs/querying/sql-operators.md
index d3cb75f26d..22e2162894 100644
--- a/docs/querying/sql-operators.md
+++ b/docs/querying/sql-operators.md
@@ -37,6 +37,13 @@ sidebar_label: "Operators"
Operators in [Druid SQL](./sql.md) typically operate on one or two values and
return a result based on the values. Types of operators in Druid SQL include
arithmetic, comparison, logical, and more, as described here.
+When performing math operations, Druid uses 64-bit integer (long) data type
unless there are double or float values. If an operation uses float or double
values, then the result is a double, which is a 64-bit float. The precision of
float and double values is defined by
[Java](https://docs.oracle.com/javase/specs/jls/se8/html/jls-5.html) and [the
IEEE standard](https://en.wikipedia.org/wiki/IEEE_754).
+
+Keep the following guidelines in mind to help you manage precision issues:
+
+- Long values can store up to 2^63 accurately with an additional bit used for
the sign.
+- Float values use 32 bits, and doubles use 64 bits. Both types are impacted
by floating point precision. If you need exact decimal values, consider storing
the number in a non-decimal format as a long value (up to the limit for longs).
For example, if you need three decimal places, store the number multiplied by
1000 and then divide by 1000 when querying.
+
## Arithmetic operators
|Operator|Description|
---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]