How to raise a number to a power?

Rust provides exponentiation via methods pow and checked_pow. The latter
guards against overflows. Thus, to raise 2 to the power of 10, do:

let base: i32 = 2; // an explicit type is required
assert_eq!(base.pow(10), 1024);

The caret operator ^ is not used for exponentiation, it’s the bitwise XOR
operator.

Leave a Comment

Hata!: SQLSTATE[HY000] [1045] Access denied for user 'divattrend_liink'@'localhost' (using password: YES)