Helper function used for dividing the end-point values of intervals. Caution:** This function contains multiple calls to `unwrap()`, and may return non-standardized interval bounds. Therefore, it should be used with caution. Currently, it is used in contexts where the `DataType` (`dt`) is validated prior to calling this function, and the following interval creation is standardized with `Interval:
(
dt: &DataType,
lhs: &ScalarValue,
rhs: &ScalarValue,
)
| 1144 | /// (`dt`) is validated prior to calling this function, and the following |
| 1145 | /// interval creation is standardized with `Interval::new`. |
| 1146 | fn div_bounds<const UPPER: bool>( |
| 1147 | dt: &DataType, |
| 1148 | lhs: &ScalarValue, |
| 1149 | rhs: &ScalarValue, |
| 1150 | ) -> ScalarValue { |
| 1151 | let zero = ScalarValue::new_zero(dt).unwrap(); |
| 1152 | |
| 1153 | if (lhs.is_null() || rhs.eq(&zero)) || (dt.is_unsigned_integer() && rhs.is_null()) { |
| 1154 | return ScalarValue::try_from(dt).unwrap(); |
| 1155 | } else if rhs.is_null() { |
| 1156 | return zero; |
| 1157 | } |
| 1158 | |
| 1159 | match dt { |
| 1160 | DataType::Float64 | DataType::Float32 => { |
| 1161 | alter_fp_rounding_mode::<UPPER, _>(lhs, rhs, |lhs, rhs| lhs.div(rhs)) |
| 1162 | } |
| 1163 | _ => lhs.div(rhs), |
| 1164 | } |
| 1165 | .unwrap_or_else(|_| handle_overflow::<UPPER>(dt, Operator::Divide, lhs, rhs)) |
| 1166 | } |
| 1167 | |
| 1168 | /// This function handles cases where an operation results in an overflow. Such |
| 1169 | /// results are converted to an *unbounded endpoint* if: |