You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
Fix precision loss in CastExpr::check_bigger_cast for integer-to-float conversions #23808
CastExpr::check_bigger_cast is used to determine whether a cast is a widening (order-preserving) conversion. Currently, it classifies all (Int8 | Int16 | Int32 | UInt8 | UInt16 | UInt32) -> (Float32 | Float64) and (Int64 | UInt64) -> Float64 as widening casts.
However, integer-to-float conversions can lose precision when the integer value exceeds the mantissa bit limit (24 bits for Float32, 53 bits for Float64).
For example, Int32 -> Float32 loses precision for integers greater than 2^24 (16,777,216):
Because distinct integer inputs can collapse to the same float output, these casts are not strictly 1-to-1 (injective). When used in multi-column ordering analysis (e.g. [CAST(a AS Float32), b]), this value collapse can invalidate the ordering of subsequent sort keys (b).
What changes should be made?
Modify CastExpr::check_bigger_cast to only treat integer-to-float conversions without precision loss as widening casts:
Activity
fix: exclude precision-losing integer-to-float conversions from CastE…
fix: exclude precision-losing integer-to-float conversions from CastE…
fix: exclude precision-losing integer-to-float conversions from CastE…