Type ::std::i64
The primitive integer type.
Methods
Compares and returns the maximum of two values.
Returns the second argument if the comparison determines them to be equal.
Examples
assert_eq!;
assert_eq!;
Compares and returns the minimum of two values.
Returns the first argument if the comparison determines them to be equal.
Examples
assert_eq!;
assert_eq!;
Computes the absolute value of self
.
Overflow behavior
The absolute value of i64::MIN
cannot be represented as an int
, and attempting to calculate it will cause an overflow. This means that such code will wrap to i64::MIN
without a panic.
Examples
Basic usage:
assert_eq!;
assert_eq!;
Raises self to the power of exp
, using exponentiation by squaring.
Overflow behavior
This function will wrap on overflow.
Examples
Basic usage:
let x = 2;
assert_eq!;
Checked integer addition. Computes self + rhs
, returning None
if overflow occurred.
Examples
Basic usage:
assert_eq!;
assert_eq!;
Checked integer subtraction. Computes self - rhs
, returning None
if overflow occurred.
Examples
Basic usage:
assert_eq!;
assert_eq!;
Checked integer division. Computes self / rhs
, returning None
if rhs == 0
or the division results in overflow.
Examples
Basic usage:
assert_eq!;
assert_eq!;
assert_eq!;
Checked integer multiplication. Computes self * rhs
, returning None
if overflow occurred.
Examples
Basic usage:
assert_eq!;
assert_eq!;
Checked integer remainder. Computes self % rhs
, returning None
if rhs == 0
or the division results in overflow.
Examples
Basic usage:
assert_eq!;
assert_eq!;
assert_eq!;
Wrapping (modular) addition. Computes self + rhs
, wrapping around at the boundary of the type.
Examples
Basic usage:
assert_eq!;
assert_eq!;
Wrapping (modular) subtraction. Computes self - rhs
, wrapping around at the boundary of the type.
Examples
Basic usage:
Wrapping (modular) division. Computes self / rhs
, wrapping around at the boundary of the type.
The only case where such wrapping can occur is when one divides MIN / -1
on a signed type (where MIN
is the negative minimal value for the type); this is equivalent to -MIN
, a positive value that is too large to represent in the type. In such a case, this function returns MIN
itself.
Panics
This function will panic if rhs
is 0.
Examples
Basic usage:
assert_eq!;
Wrapping (modular) multiplication. Computes self * rhs
, wrapping around at the boundary of the type.
Examples
Basic usage:
assert_eq!;
Wrapping (modular) remainder. Computes self % rhs
, wrapping around at the boundary of the type.
Such wrap-around never actually occurs mathematically; implementation artifacts make x % y
invalid for MIN / -1
on a signed type (where MIN
is the negative minimal value). In such a case, this function returns 0
.
Panics
This function will panic if rhs
is 0.
Examples
Basic usage:
assert_eq!;
Saturating integer addition. Computes self + rhs
, saturating at the numeric bounds instead of overflowing.
Examples
Basic usage:
assert_eq!;
assert_eq!;
assert_eq!;
Saturating integer subtraction. Computes self - rhs
, saturating at the numeric bounds instead of overflowing.
Examples
Basic usage:
assert_eq!;
assert_eq!;
assert_eq!;
Saturating integer multiplication. Computes self * rhs
, saturating at the numeric bounds instead of overflowing.
Examples
Basic usage:
assert_eq!;
assert_eq!;
assert_eq!;
Saturating absolute value. Computes self.abs()
, returning MAX
if self == MIN
instead of overflowing.
Examples
Basic usage:
assert_eq!;
assert_eq!;
assert_eq!;
assert_eq!;
Saturating integer exponentiation. Computes self.pow(exp)
, saturating at the numeric bounds instead of overflowing.
Examples
Basic usage:
assert_eq!;
assert_eq!;
assert_eq!;
Returns a number representing sign of self
.
0
if the number is zero1
if the number is positive-1
if the number is negative
Examples
Basic usage:
assert_eq!;
assert_eq!;
assert_eq!;
Returns true
if self
is positive and false
if the number is zero or negative.
Examples
Basic usage:
assert!;
assert!;
Returns true
if self
is negative and false
if the number is zero or positive.
Examples
Basic usage:
assert!;
assert!;
Returns the number as a string.
Examples
Basic usage:
assert_eq!;
assert_eq!;
Protocols
if value == b
Test two integers for partial equality.
Examples
use partial_eq;
assert_eq!;
assert_eq!;
assert_eq!;
if value == b
Test two integers for total equality.
Examples
use eq;
assert_eq!;
assert_eq!;
assert_eq!;
if value < b
Perform a partial ordered comparison between two integers.
Examples
use Ordering;
use partial_cmp;
assert_eq!;
assert_eq!;
assert_eq!;
if value < b
Perform a partial ordered comparison between two integers.
Examples
use Ordering;
use cmp;
assert_eq!;
assert_eq!;
assert_eq!;