Fallback implementation using f64 for negative or non-integer exponents. This handles cases that cannot be computed using integer arithmetic.
(base: T, scale: i8, exp: f64)
| 252 | /// Fallback implementation using f64 for negative or non-integer exponents. |
| 253 | /// This handles cases that cannot be computed using integer arithmetic. |
| 254 | fn pow_decimal_float_fallback<T>(base: T, scale: i8, exp: f64) -> Result<T, ArrowError> |
| 255 | where |
| 256 | T: ToPrimitive + NumCast + Copy, |
| 257 | { |
| 258 | if scale < 0 { |
| 259 | return Err(ArrowError::NotYetImplemented(format!( |
| 260 | "Negative scale is not yet supported: {scale}" |
| 261 | ))); |
| 262 | } |
| 263 | |
| 264 | let scale_factor = 10f64.powi(scale as i32); |
| 265 | let base_f64 = base.to_f64().ok_or_else(|| { |
| 266 | ArrowError::ComputeError("Cannot convert base to f64".to_string()) |
| 267 | })? / scale_factor; |
| 268 | |
| 269 | let result_i128 = compute_pow_f64_result(base_f64, scale, exp)?; |
| 270 | |
| 271 | decimal_from_i128(result_i128) |
| 272 | } |
| 273 | |
| 274 | /// Decimal256 specialized float exponent version. |
| 275 | fn pow_decimal256_float(base: i256, scale: i8, exp: f64) -> Result<i256, ArrowError> { |
no test coverage detected
searching dependent graphs…