ektravel commented on code in PR #13671: URL: https://github.com/apache/druid/pull/13671#discussion_r1119061858
########## 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 are 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 3 decimal places, store the number multiplied by 1000 and then divide by 1000 when querying. Review Comment: ```suggestion - 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. ``` -- This is an automated message from the Apache Git Service. To respond to the message, please log on to GitHub and use the URL above to go to the specific comment. To unsubscribe, e-mail: [email protected] For queries about this service, please contact Infrastructure at: [email protected] --------------------------------------------------------------------- To unsubscribe, e-mail: [email protected] For additional commands, e-mail: [email protected]
