MCPcopy Create free account
hub / github.com/RustCrypto/utils / overflowing_add_u64

Function overflowing_add_u64

ctutils/src/primitives.rs:288–292  ·  view source on GitHub ↗
(lhs: u64, rhs: u64)

Source from the content-addressed store, hash-verified

286#[inline]
287#[must_use]
288pub const fn overflowing_add_u64(lhs: u64, rhs: u64) -> (u64, Choice) {
289 let sum = lhs.wrapping_add(rhs);
290 let carry = ((lhs & rhs) | ((lhs | rhs) & !sum)) >> (u64::BITS - 1);
291 (sum, Choice::from_u64_lsb(carry))
292}
293
294/// Add two integers, returning the wrapping sum and [`Choice::TRUE`] on overflow.
295#[inline]

Callers 1

Calls 1

from_u64_lsbFunction · 0.85

Tested by

no test coverage detected