hello-stephen commented on code in PR #71094:
URL: https://github.com/apache/doris/pull/71094#discussion_r4735842919


##########
be/src/exprs/function/round.h:
##########
@@ -329,6 +379,11 @@ class FloatRoundingComputation : public 
BaseFloatRoundingComputation<T, tie_brea
             val = Base::divide(val, scale);
         } else if (scale_mode == ScaleMode::Negative) {
             val = Base::multiply(val, scale);
+            // For example, ceil(1.7e308, -308) needs 2e308, which DOUBLE 
cannot store.
+            if (!std::isfinite(val)) {

Review Comment:
   [P2] Preserve finite results when the scale round trip overflows
   
   For a DOUBLE column containing `1.7976931348623157e308` (`DOUBLE_MAX`), 
`round(x, -20)` now throws here: dividing by the new `1e20` factor yields 
`1.7976931348623158e288`, which is already integral, but multiplying it back 
overflows. Rounding this input to a multiple of `10^20` should still produce 
the original finite DOUBLE, since that unit is far below its ULP. The base 
returned it unchanged because the saturated factor converted to exact `2^64`. 
This also affects `floor`, `ceil`, `truncate`, and `round_bankers`. Preserve 
the finite result for this intermediate-rounding case and cover it in the 
argument-shape tests.



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

Reply via email to