Signed 64-bit integer
Methods
impl i64 { ... }
-
fn max_value() -> i64
Returns the maximum value of
i64
. -
fn min_value() -> i64
Returns the minimum value of
i64
.
Mixins
impl i64 { ... }
-
mixin WithOverflow<i64>
-
Adds two numbers, wrapping around at the boundary of the type.
-
Subtracts two numbers, wrapping around at the boundary of the type.
-
Multiplies two numbers, wrapping around at the boundary of the type.
-
Divides two numbers, 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. This is equivalent to-MIN
, a number that is too large to represent in the type. In such a case, this function returnsMIN
itself. -
Tries to add two numbers, returning
Option::none()
if overflow occurrs. -
Tries to subtract two numbers, returning
Option::none()
if overflow occurrs. -
Tries to multiply two numbers, returning
Option::none()
if overflow occurrs. -
Tries to divide two numbers, returning
Option::none()
if overflow occurrs orrhs
is zero.Overflow during division can only happen when one divides
MIN / -1
on a signed type. -
mixin BuiltinComparable<i64>
-
Returns
false
if arguments are equal,true
otherwise -
Returns
true
iflhs
is strictly less thanrhs
,false
otherwise -
Returns
true
iflhs
is less or equal torhs
,false
otherwise -
Returns
true
iflhs
strictly greater thanrhs
,false
otherwise -
Returns
true
iflhs
greater than or equalrhs
,false
otherwise -
mixin<H> IntegerHashable<i64, H>
H: Hasher<H> -
fn hash(self: &Self, hasher: &mut H)
-
mixin<F> IntegerFormattable<i64, F>
F: Formatter<F> -
mixin IntegerParsable<i64>
-
Parses the integer from a base-10 string.
If the string does not represent a valid integer,
Option::none()
is returned.Example
assert_eq!(i32::parse("10"), Option::some(10)); assert_eq!(i32::parse("foo"), Option::none());
Run this example -
Parses the integer from a string in a given base.
If the string does not represent a valid integer in the given base,
Option::none()
is returned.Example
assert_eq!(i32::parse_with_radix("10", 2), Option::some(2)); assert_eq!(u64::parse_with_radix("deadbeef", 16), Option::some(0xdeadbeefu64)); assert_eq!(i32::parse_with_radix("foo", 10), Option::none());
Run this example