kosiew opened a new issue, #7985: URL: https://github.com/apache/arrow-rs/issues/7985
## Background - **Current behavior:** the latest commit in #7887 removed the panic on overflow and now **saturates** any out-of-range `Decimal256` → `Float64` conversions to `f64::INFINITY` or `f64::NEG_INFINITY`. - **Why that’s sub-optimal:** although this avoids crashes, it still injects infinities for large values—yet in fact [**every** 256-bit integer fits in f64’s exponent range (±2¹⁰²³)](https://github.com/apache/arrow-rs/pull/7887#discussion_r2217478275). We only ever lose precision in the mantissa, never dynamic range. ## Proposal Override `ToPrimitive::to_f64` for `i256` so that: 1. **No panics** (we’ll never call `.unwrap()` or fall through to `None`). 2. **No infinities**—every value maps to a finite, rounded `f64`. 3. **Behavior matches** Rust’s built-in `(i128) as f64` logic: ties-to-even rounding, full exponent coverage. ### Suggested implementation in `arrow-buffer/src/bigint/mod.rs` ```rust impl ToPrimitive for i256 { fn to_f64(&self) -> Option<f64> { // Handle the one case where abs() would overflow: i256::MIN let mag = if let Some(abs) = self.checked_abs() { // Break the magnitude into (low: u128, high: i128) let (low, high) = abs.to_parts(); // Recombine: high * 2^128 + low (high as f64) * 2_f64.powi(128) + (low as f64) } else { // self == i256::MIN → exactly 2^255 2_f64.powi(255) }; // Reapply the sign bit Some(if *self < i256::ZERO { -mag } else { mag }) } // ... other methods unchanged ... } -- 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: github-unsubscr...@arrow.apache.org.apache.org For queries about this service, please contact Infrastructure at: us...@infra.apache.org