tanclary commented on PR #3234:
URL: https://github.com/apache/calcite/pull/3234#issuecomment-1625641445

   > If I were to make `safeDouble` always return true, would any tests fail?
   > 
   > If I wrote
   > 
   > ```
   > boolean safeBoolean(boolean b) {
   >   return b == true || b == false;
   > }
   > ```
   > 
   > it's obvious that it will always return true. But I don't see how 
`safeDouble` is any different, because you've already dealt with inf and -inf. 
Maybe you just need to check for NaN. `java.lang.Double` has methods for that 
kind of thing.
   
   The answer to your first question is yes. Following BQ behavior, multiplying 
two non-infinite numbers whose result is > ~1.7e308 should return `NULL`. 
However, if either operand is infinite, the result should not be `NULL`. To 
match this, I check if either number is +/- inf, and then continue accordingly.
   
   For example, `(+inf * 1)` and `(1.7e308 * 2)` should return different 
results (the first: `+inf`, the second: `NULL`) despite the fact that Java 
would tell you the answer to both is `+inf`.
   
   You are right though that I need to address `NaN`.


-- 
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]

Reply via email to