tustvold commented on code in PR #3943:
URL: https://github.com/apache/arrow-rs/pull/3943#discussion_r1148448678


##########
arrow-buffer/src/bigint.rs:
##########
@@ -259,9 +258,8 @@ impl i256 {
     /// Performs checked subtraction
     #[inline]
     pub fn checked_sub(self, other: Self) -> Option<Self> {
-        let (low, carry) = self.low.overflowing_sub(other.low);
-        let high = self.high.checked_sub(other.high)?.checked_sub(carry as _)?;
-        Some(Self { low, high })

Review Comment:
   Consider the case
   
   ```
   i256::from_parts(0, i128::MAX).checked_sub(i256::MINUS_ONE).unwrap();
   ```
   
   The carry is enough to reduce `i128::MAX` enough that subtracting `-1` does 
not result in overflow



-- 
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: [email protected]

For queries about this service, please contact Infrastructure at:
[email protected]

Reply via email to