You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@druid.apache.org by vi...@apache.org on 2023/03/15 18:43:50 UTC

[druid] branch master updated: docs: clarify Java precision (#13671)

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 <53...@users.noreply.github.com>
AuthorDate: Wed Mar 15 11:43:41 2023 -0700

    docs: clarify Java precision (#13671)
    
    Co-authored-by: Katya Macedo  <38...@users.noreply.github.com>
    Co-authored-by: Victoria Lim <vt...@users.noreply.github.com>
---
 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: commits-unsubscribe@druid.apache.org
For additional commands, e-mail: commits-help@druid.apache.org