本文簡要介紹rust語言中 u64.overflowing_add_signed
的用法。
用法
pub fn overflowing_add_signed(self, rhs: i64) -> (u64, bool)
計算 self
+ rhs
並帶有簽名的 rhs
返回一個加法元組以及一個指示是否會發生算術溢出的布爾值。如果發生溢出,則返回包裝的值。
例子
基本用法:
assert_eq!(1u64.overflowing_add_signed(2), (3, false));
assert_eq!(1u64.overflowing_add_signed(-2), (u64::MAX, true));
assert_eq!((u64::MAX - 2).overflowing_add_signed(4), (1, true));
相關用法
- Rust u64.overflowing_add用法及代碼示例
- Rust u64.overflowing_mul用法及代碼示例
- Rust u64.overflowing_sub用法及代碼示例
- Rust u64.overflowing_rem_euclid用法及代碼示例
- Rust u64.overflowing_neg用法及代碼示例
- Rust u64.overflowing_rem用法及代碼示例
- Rust u64.overflowing_div_euclid用法及代碼示例
- Rust u64.overflowing_pow用法及代碼示例
- Rust u64.overflowing_div用法及代碼示例
- Rust u64.overflowing_shl用法及代碼示例
- Rust u64.overflowing_shr用法及代碼示例
- Rust u64.rotate_right用法及代碼示例
- Rust u64.log用法及代碼示例
- Rust u64.carrying_mul用法及代碼示例
- Rust u64.from_le_bytes用法及代碼示例
- Rust u64.wrapping_shl用法及代碼示例
- Rust u64.wrapping_shr用法及代碼示例
- Rust u64.checked_log用法及代碼示例
- Rust u64.checked_next_power_of_two用法及代碼示例
- Rust u64.unstable_next_multiple_of用法及代碼示例
- Rust u64.log2用法及代碼示例
- Rust u64.wrapping_rem_euclid用法及代碼示例
- Rust u64.swap_bytes用法及代碼示例
- Rust u64.checked_add用法及代碼示例
- Rust u64.saturating_pow用法及代碼示例
注:本文由純淨天空篩選整理自rust-lang.org大神的英文原創作品 u64.overflowing_add_signed。非經特殊聲明,原始代碼版權歸原作者所有,本譯文未經允許或授權,請勿轉載或複製。