alamb commented on code in PR #11425:
URL: https://github.com/apache/arrow-rs/pull/11425#discussion_r4222316340
##########
arrow-buffer/src/bigint/mod.rs:
##########
@@ -572,6 +568,61 @@ impl i256 {
self.div_rem(other).map(|(_, v)| v).ok()
}
+ /// Performs wrapping division and remainder, returning `(quotient,
remainder)`
+ ///
+ /// This computes both results with one division, while calling
+ /// [`Self::wrapping_div`] and [`Self::wrapping_rem`] divides twice.
+ ///
+ /// The quotient is truncated toward zero, and the remainder has the sign
of
+ /// `self`. `i256::MIN / -1` wraps to `(i256::MIN, 0)`.
+ ///
+ /// # Panics
+ ///
+ /// Panics if `other` is zero
+ ///
+ /// # Example
+ /// ```
+ /// # use arrow_buffer::i256;
+ /// let (q, r) = i256::from_i128(-7).wrapping_div_rem(i256::from_i128(2));
+ /// assert_eq!((q, r), (i256::from_i128(-3), i256::from_i128(-1)));
+ ///
+ /// let (q, r) = i256::MIN.wrapping_div_rem(i256::MINUS_ONE);
+ /// assert_eq!((q, r), (i256::MIN, i256::ZERO));
Review Comment:
👍
--
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]