std-method

Integer overflowing_mul and overflowing_pow

Use the overflow flag to decide whether a computed product or power is acceptable. Expected stdout (not executed): (0, true) (81, false) Common mistake: Interpreting a wrapped zero as proof the actual product was zero.

Formal Syntax & Structure

rust syntaxrust
x.overflowing_mul(y); x.overflowing_pow(exp)

Working Example

Example Snippetrust
fn main() {    println!("{:?}", 16u8.overflowing_mul(16));    println!("{:?}", 3u8.overflowing_pow(4));}
Rust Reference