tanclary commented on code in PR #3378:
URL: https://github.com/apache/calcite/pull/3378#discussion_r1300364855
##########
core/src/main/java/org/apache/calcite/runtime/SqlFunctions.java:
##########
@@ -1859,7 +1983,7 @@ private static boolean safeDouble(double d) {
// negated MIN and MAX double values, overflow has not occurred. Otherwise,
// overflow has occurred. Important to note that 'Double.MIN_VALUE' refers
to
// minimum positive value.
- if (d < Double.MAX_VALUE && d > Double.MIN_VALUE) {
+ if (d < Double.MAX_VALUE && d > Double.MIN_VALUE || d == 0) {
Review Comment:
The way I check if a `Double` is "safe" or not is by checking whether it
falls within the following ranges:
`Largest Negative Value` < `value` < `Smallest negative value`
or
`Smallest positive value` < `value` < `Largest positive value`
The exception to this is zero, so I check for that as well.
Let me know if this makes sense or you think it should be changed.
--
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]