kosiew commented on code in PR #7986: URL: https://github.com/apache/arrow-rs/pull/7986#discussion_r2230034439
########## arrow-cast/src/cast/mod.rs: ########## @@ -1995,15 +1995,37 @@ where } } -/// Convert a [`i256`] to `f64` saturating to infinity on overflow. -fn decimal256_to_f64(v: i256) -> f64 { - v.to_f64().unwrap_or_else(|| { - if v.is_negative() { - f64::NEG_INFINITY - } else { - f64::INFINITY - } - }) +/// Converts a 256-bit signed integer to a 64-bit floating point number. +/// +/// This function is primarily used for converting Decimal256 values to f64, +/// where the Decimal256 is represented as an i256 (256-bit signed integer). +/// +/// # Arguments +/// +/// * `val` - The 256-bit signed integer value to convert +/// +/// # Returns +/// +/// Returns the floating point representation of the input value. +/// +/// All `i256` values are within the representable range of `f64`. The +/// conversion therefore cannot overflow, although large values may lose +/// precision. +/// +/// # Examples +////// ``` +/// use arrow_buffer::i256; +/// use arrow_cast::cast::decimal256_to_f64; +/// +/// let val = i256::from(123456789); +/// let result = decimal256_to_f64(val); +/// assert_eq!(result, 123456789.0); +/// ``` +pub fn decimal256_to_f64(val: i256) -> f64 { Review Comment: hi @scovich Implemented -- 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 For queries about this service, please contact Infrastructure at: us...@infra.apache.org