macro_rules! zero_one_impl {
($($t:ty)*) => ($(
+ #[unstable(feature = "zero_one",
+ reason = "unsure of placement, wants to use associated constants",
+ issue = "27739")]
impl Zero for $t {
#[inline]
fn zero() -> Self { 0 }
}
+ #[unstable(feature = "zero_one",
+ reason = "unsure of placement, wants to use associated constants",
+ issue = "27739")]
impl One for $t {
#[inline]
fn one() -> Self { 1 }
macro_rules! zero_one_impl_float {
($($t:ty)*) => ($(
+ #[unstable(feature = "zero_one",
+ reason = "unsure of placement, wants to use associated constants",
+ issue = "27739")]
impl Zero for $t {
#[inline]
fn zero() -> Self { 0.0 }
}
+ #[unstable(feature = "zero_one",
+ reason = "unsure of placement, wants to use associated constants",
+ issue = "27739")]
impl One for $t {
#[inline]
fn one() -> Self { 1.0 }
/// Returns the smallest value that can be represented by this integer type.
#[stable(feature = "rust1", since = "1.0.0")]
#[inline]
- pub fn min_value() -> Self {
+ pub const fn min_value() -> Self {
(-1 as Self) << ($BITS - 1)
}
/// Returns the largest value that can be represented by this integer type.
#[stable(feature = "rust1", since = "1.0.0")]
#[inline]
- pub fn max_value() -> Self {
- let min = Self::min_value(); !min
+ pub const fn max_value() -> Self {
+ !Self::min_value()
}
/// Converts a string slice in a given base to an integer.
///
/// # Examples
///
+ /// Basic usage:
+ ///
/// ```
/// assert_eq!(u32::from_str_radix("A", 16), Ok(10));
/// ```
///
/// # Examples
///
- /// ```rust
+ /// Basic usage:
+ ///
+ /// ```
/// let n = 0b01001100u8;
///
/// assert_eq!(n.count_ones(), 3);
///
/// # Examples
///
- /// ```rust
+ /// Basic usage:
+ ///
+ /// ```
/// let n = 0b01001100u8;
///
/// assert_eq!(n.count_zeros(), 5);
///
/// # Examples
///
- /// ```rust
+ /// Basic usage:
+ ///
+ /// ```
/// let n = 0b0101000u16;
///
/// assert_eq!(n.leading_zeros(), 10);
///
/// # Examples
///
- /// ```rust
+ /// Basic usage:
+ ///
+ /// ```
/// let n = 0b0101000u16;
///
/// assert_eq!(n.trailing_zeros(), 3);
///
/// # Examples
///
- /// ```rust
+ /// Basic usage:
+ ///
+ /// ```
/// let n = 0x0123456789ABCDEFu64;
/// let m = 0x3456789ABCDEF012u64;
///
///
/// # Examples
///
- /// ```rust
+ /// Basic usage:
+ ///
+ /// ```
/// let n = 0x0123456789ABCDEFu64;
/// let m = 0xDEF0123456789ABCu64;
///
///
/// # Examples
///
- /// ```rust
+ /// Basic usage:
+ ///
+ /// ```
/// let n = 0x0123456789ABCDEFu64;
/// let m = 0xEFCDAB8967452301u64;
///
///
/// # Examples
///
- /// ```rust
+ /// Basic usage:
+ ///
+ /// ```
/// let n = 0x0123456789ABCDEFu64;
///
/// if cfg!(target_endian = "big") {
///
/// # Examples
///
- /// ```rust
+ /// Basic usage:
+ ///
+ /// ```
/// let n = 0x0123456789ABCDEFu64;
///
/// if cfg!(target_endian = "little") {
///
/// # Examples
///
- /// ```rust
+ /// Basic usage:
+ ///
+ /// ```
/// let n = 0x0123456789ABCDEFu64;
///
/// if cfg!(target_endian = "big") {
///
/// # Examples
///
- /// ```rust
+ /// Basic usage:
+ ///
+ /// ```
/// let n = 0x0123456789ABCDEFu64;
///
/// if cfg!(target_endian = "little") {
///
/// # Examples
///
- /// ```rust
+ /// Basic usage:
+ ///
+ /// ```
/// assert_eq!(5u16.checked_add(65530), Some(65535));
/// assert_eq!(6u16.checked_add(65530), None);
/// ```
///
/// # Examples
///
- /// ```rust
+ /// Basic usage:
+ ///
+ /// ```
/// assert_eq!((-127i8).checked_sub(1), Some(-128));
/// assert_eq!((-128i8).checked_sub(1), None);
/// ```
///
/// # Examples
///
- /// ```rust
+ /// Basic usage:
+ ///
+ /// ```
/// assert_eq!(5u8.checked_mul(51), Some(255));
/// assert_eq!(5u8.checked_mul(52), None);
/// ```
///
/// # Examples
///
- /// ```rust
+ /// Basic usage:
+ ///
+ /// ```
/// assert_eq!((-127i8).checked_div(-1), Some(127));
/// assert_eq!((-128i8).checked_div(-1), None);
/// assert_eq!((1i8).checked_div(0), None);
/// Saturating integer addition. Computes `self + other`, saturating at
/// the numeric bounds instead of overflowing.
+ ///
+ /// # Examples
+ ///
+ /// Basic usage:
+ ///
+ /// ```
+ /// assert_eq!(100i8.saturating_add(1), 101);
+ /// assert_eq!(100i8.saturating_add(127), 127);
+ /// ```
#[stable(feature = "rust1", since = "1.0.0")]
#[inline]
pub fn saturating_add(self, other: Self) -> Self {
/// Saturating integer subtraction. Computes `self - other`, saturating
/// at the numeric bounds instead of overflowing.
+ ///
+ /// # Examples
+ ///
+ /// Basic usage:
+ ///
+ /// ```
+ /// assert_eq!(100i8.saturating_sub(127), -27);
+ /// assert_eq!((-100i8).saturating_sub(127), -128);
+ /// ```
#[stable(feature = "rust1", since = "1.0.0")]
#[inline]
pub fn saturating_sub(self, other: Self) -> Self {
/// Wrapping (modular) addition. Computes `self + other`,
/// wrapping around at the boundary of the type.
+ ///
+ /// # Examples
+ ///
+ /// Basic usage:
+ ///
+ /// ```
+ /// assert_eq!(100i8.wrapping_add(27), 127);
+ /// assert_eq!(100i8.wrapping_add(127), -29);
+ /// ```
#[stable(feature = "rust1", since = "1.0.0")]
#[inline]
pub fn wrapping_add(self, rhs: Self) -> Self {
/// Wrapping (modular) subtraction. Computes `self - other`,
/// wrapping around at the boundary of the type.
+ ///
+ /// # Examples
+ ///
+ /// Basic usage:
+ ///
+ /// ```
+ /// assert_eq!(0i8.wrapping_sub(127), -127);
+ /// assert_eq!((-2i8).wrapping_sub(127), 127);
+ /// ```
#[stable(feature = "rust1", since = "1.0.0")]
#[inline]
pub fn wrapping_sub(self, rhs: Self) -> Self {
/// Wrapping (modular) multiplication. Computes `self *
/// other`, wrapping around at the boundary of the type.
+ ///
+ /// # Examples
+ ///
+ /// Basic usage:
+ ///
+ /// ```
+ /// assert_eq!(10i8.wrapping_mul(12), 120);
+ /// assert_eq!(11i8.wrapping_mul(12), -124);
+ /// ```
#[stable(feature = "rust1", since = "1.0.0")]
#[inline]
pub fn wrapping_mul(self, rhs: Self) -> Self {
/// to `-MIN`, a positive value that is too large to represent
/// in the type. In such a case, this function returns `MIN`
/// itself.
+ ///
+ /// # Examples
+ ///
+ /// Basic usage:
+ ///
+ /// ```
+ /// assert_eq!(100u8.wrapping_div(10), 10);
+ /// assert_eq!((-128i8).wrapping_div(-1), -128);
+ /// ```
#[stable(feature = "num_wrapping", since = "1.2.0")]
#[inline(always)]
pub fn wrapping_div(self, rhs: Self) -> Self {
/// 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`.
+ ///
+ /// # Examples
+ ///
+ /// Basic usage:
+ ///
+ /// ```
+ /// assert_eq!(100i8.wrapping_rem(10), 0);
+ /// assert_eq!((-128i8).wrapping_rem(-1), 0);
+ /// ```
#[stable(feature = "num_wrapping", since = "1.2.0")]
#[inline(always)]
pub fn wrapping_rem(self, rhs: Self) -> Self {
/// negative minimal value for the type); this is a positive
/// value that is too large to represent in the type. In such
/// a case, this function returns `MIN` itself.
+ ///
+ /// # Examples
+ ///
+ /// Basic usage:
+ ///
+ /// ```
+ /// assert_eq!(100i8.wrapping_neg(), -100);
+ /// assert_eq!((-128i8).wrapping_neg(), -128);
+ /// ```
#[stable(feature = "num_wrapping", since = "1.2.0")]
#[inline(always)]
pub fn wrapping_neg(self) -> Self {
/// Panic-free bitwise shift-left; yields `self << mask(rhs)`,
/// where `mask` removes any high-order bits of `rhs` that
/// would cause the shift to exceed the bitwidth of the type.
+ ///
+ /// # Examples
+ ///
+ /// Basic usage:
+ ///
+ /// ```
+ /// assert_eq!(1u8.wrapping_shl(7), 128);
+ /// assert_eq!(1u8.wrapping_shl(8), 1);
+ /// ```
#[stable(feature = "num_wrapping", since = "1.2.0")]
#[inline(always)]
pub fn wrapping_shl(self, rhs: u32) -> Self {
/// Panic-free bitwise shift-left; yields `self >> mask(rhs)`,
/// where `mask` removes any high-order bits of `rhs` that
/// would cause the shift to exceed the bitwidth of the type.
+ ///
+ /// # Examples
+ ///
+ /// Basic usage:
+ ///
+ /// ```
+ /// assert_eq!(128u8.wrapping_shr(7), 1);
+ /// assert_eq!(128u8.wrapping_shr(8), 128);
+ /// ```
#[stable(feature = "num_wrapping", since = "1.2.0")]
#[inline(always)]
pub fn wrapping_shr(self, rhs: u32) -> Self {
///
/// # Examples
///
+ /// Basic usage:
+ ///
/// ```
/// let x: i32 = 2; // or any other integer type
///
/// `i32`, and attempting to calculate it will cause an overflow. This
/// means that code in debug mode will trigger a panic on this case and
/// optimized code will return `i32::min_value()` without a panic.
+ ///
+ /// # Examples
+ ///
+ /// Basic usage:
+ ///
+ /// ```
+ /// assert_eq!(10i8.abs(), 10);
+ /// assert_eq!((-10i8).abs(), 10);
+ /// ```
#[stable(feature = "rust1", since = "1.0.0")]
#[inline]
pub fn abs(self) -> Self {
/// - `0` if the number is zero
/// - `1` if the number is positive
/// - `-1` if the number is negative
+ ///
+ /// # Examples
+ ///
+ /// Basic usage:
+ ///
+ /// ```
+ /// assert_eq!(10i8.signum(), 1);
+ /// assert_eq!(0i8.signum(), 0);
+ /// assert_eq!((-10i8).signum(), -1);
+ /// ```
#[stable(feature = "rust1", since = "1.0.0")]
#[inline]
pub fn signum(self) -> Self {
/// Returns `true` if `self` is positive and `false` if the number
/// is zero or negative.
+ ///
+ /// # Examples
+ ///
+ /// Basic usage:
+ ///
+ /// ```
+ /// assert!(10i8.is_positive());
+ /// assert!(!(-10i8).is_positive());
+ /// ```
#[stable(feature = "rust1", since = "1.0.0")]
#[inline]
pub fn is_positive(self) -> bool { self > 0 }
/// Returns `true` if `self` is negative and `false` if the number
/// is zero or positive.
+ ///
+ /// # Examples
+ ///
+ /// Basic usage:
+ ///
+ /// ```
+ /// assert!((-10i8).is_negative());
+ /// assert!(!10i8.is_negative());
+ /// ```
#[stable(feature = "rust1", since = "1.0.0")]
#[inline]
pub fn is_negative(self) -> bool { self < 0 }
/// Returns the smallest value that can be represented by this integer type.
#[stable(feature = "rust1", since = "1.0.0")]
#[inline]
- pub fn min_value() -> Self { 0 }
+ pub const fn min_value() -> Self { 0 }
/// Returns the largest value that can be represented by this integer type.
#[stable(feature = "rust1", since = "1.0.0")]
#[inline]
- pub fn max_value() -> Self { !0 }
+ pub const fn max_value() -> Self { !0 }
/// Converts a string slice in a given base to an integer.
///
///
/// # Examples
///
- /// ```rust
+ /// Basic usage:
+ ///
+ /// ```
/// let n = 0b01001100u8;
///
/// assert_eq!(n.count_ones(), 3);
///
/// # Examples
///
- /// ```rust
+ /// Basic usage:
+ ///
+ /// ```
/// let n = 0b01001100u8;
///
/// assert_eq!(n.count_zeros(), 5);
///
/// # Examples
///
- /// ```rust
+ /// Basic usage:
+ ///
+ /// ```
/// let n = 0b0101000u16;
///
/// assert_eq!(n.leading_zeros(), 10);
///
/// # Examples
///
- /// ```rust
+ /// Basic usage:
+ ///
+ /// ```
/// let n = 0b0101000u16;
///
/// assert_eq!(n.trailing_zeros(), 3);
///
/// # Examples
///
- /// ```rust
+ /// Basic usage:
+ ///
+ /// ```
/// let n = 0x0123456789ABCDEFu64;
/// let m = 0x3456789ABCDEF012u64;
///
///
/// # Examples
///
- /// ```rust
+ /// Basic usage:
+ ///
+ /// ```
/// let n = 0x0123456789ABCDEFu64;
/// let m = 0xDEF0123456789ABCu64;
///
///
/// # Examples
///
- /// ```rust
+ /// Basic usage:
+ ///
+ /// ```
/// let n = 0x0123456789ABCDEFu64;
/// let m = 0xEFCDAB8967452301u64;
///
///
/// # Examples
///
- /// ```rust
+ /// Basic usage:
+ ///
+ /// ```
/// let n = 0x0123456789ABCDEFu64;
///
/// if cfg!(target_endian = "big") {
///
/// # Examples
///
- /// ```rust
+ /// Basic usage:
+ ///
+ /// ```
/// let n = 0x0123456789ABCDEFu64;
///
/// if cfg!(target_endian = "little") {
///
/// # Examples
///
- /// ```rust
+ /// Basic usage:
+ ///
+ /// ```
/// let n = 0x0123456789ABCDEFu64;
///
/// if cfg!(target_endian = "big") {
///
/// # Examples
///
- /// ```rust
+ /// Basic usage:
+ ///
+ /// ```
/// let n = 0x0123456789ABCDEFu64;
///
/// if cfg!(target_endian = "little") {
///
/// # Examples
///
- /// ```rust
+ /// Basic usage:
+ ///
+ /// ```
/// assert_eq!(5u16.checked_add(65530), Some(65535));
/// assert_eq!(6u16.checked_add(65530), None);
/// ```
///
/// # Examples
///
- /// ```rust
+ /// Basic usage:
+ ///
+ /// ```
/// assert_eq!((-127i8).checked_sub(1), Some(-128));
/// assert_eq!((-128i8).checked_sub(1), None);
/// ```
///
/// # Examples
///
- /// ```rust
+ /// Basic usage:
+ ///
+ /// ```
/// assert_eq!(5u8.checked_mul(51), Some(255));
/// assert_eq!(5u8.checked_mul(52), None);
/// ```
///
/// # Examples
///
- /// ```rust
+ /// Basic usage:
+ ///
+ /// ```
/// assert_eq!((-127i8).checked_div(-1), Some(127));
/// assert_eq!((-128i8).checked_div(-1), None);
/// assert_eq!((1i8).checked_div(0), None);
/// Saturating integer addition. Computes `self + other`, saturating at
/// the numeric bounds instead of overflowing.
+ ///
+ /// # Examples
+ ///
+ /// Basic usage:
+ ///
+ /// ```
+ /// assert_eq!(100i8.saturating_add(1), 101);
+ /// assert_eq!(100i8.saturating_add(127), 127);
+ /// ```
#[stable(feature = "rust1", since = "1.0.0")]
#[inline]
pub fn saturating_add(self, other: Self) -> Self {
/// Saturating integer subtraction. Computes `self - other`, saturating
/// at the numeric bounds instead of overflowing.
+ ///
+ /// # Examples
+ ///
+ /// Basic usage:
+ ///
+ /// ```
+ /// assert_eq!(100i8.saturating_sub(127), -27);
+ /// assert_eq!((-100i8).saturating_sub(127), -128);
+ /// ```
#[stable(feature = "rust1", since = "1.0.0")]
#[inline]
pub fn saturating_sub(self, other: Self) -> Self {
/// Wrapping (modular) addition. Computes `self + other`,
/// wrapping around at the boundary of the type.
+ ///
+ /// # Examples
+ ///
+ /// Basic usage:
+ ///
+ /// ```
+ /// assert_eq!(100i8.wrapping_add(27), 127);
+ /// assert_eq!(100i8.wrapping_add(127), -29);
+ /// ```
#[stable(feature = "rust1", since = "1.0.0")]
#[inline]
pub fn wrapping_add(self, rhs: Self) -> Self {
/// Wrapping (modular) subtraction. Computes `self - other`,
/// wrapping around at the boundary of the type.
+ ///
+ /// # Examples
+ ///
+ /// Basic usage:
+ ///
+ /// ```
+ /// assert_eq!(0i8.wrapping_sub(127), -127);
+ /// assert_eq!((-2i8).wrapping_sub(127), 127);
+ /// ```
#[stable(feature = "rust1", since = "1.0.0")]
#[inline]
pub fn wrapping_sub(self, rhs: Self) -> Self {
/// Wrapping (modular) multiplication. Computes `self *
/// other`, wrapping around at the boundary of the type.
+ ///
+ /// # Examples
+ ///
+ /// Basic usage:
+ ///
+ /// ```
+ /// assert_eq!(10i8.wrapping_mul(12), 120);
+ /// assert_eq!(11i8.wrapping_mul(12), -124);
+ /// ```
#[stable(feature = "rust1", since = "1.0.0")]
#[inline]
pub fn wrapping_mul(self, rhs: Self) -> Self {
/// to `-MIN`, a positive value that is too large to represent
/// in the type. In such a case, this function returns `MIN`
/// itself.
+ ///
+ /// # Examples
+ ///
+ /// Basic usage:
+ ///
+ /// ```
+ /// assert_eq!(100u8.wrapping_div(10), 10);
+ /// assert_eq!((-128i8).wrapping_div(-1), -128);
+ /// ```
#[stable(feature = "num_wrapping", since = "1.2.0")]
#[inline(always)]
pub fn wrapping_div(self, rhs: Self) -> Self {
/// 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`.
+ ///
+ /// # Examples
+ ///
+ /// Basic usage:
+ ///
+ /// ```
+ /// assert_eq!(100i8.wrapping_rem(10), 0);
+ /// assert_eq!((-128i8).wrapping_rem(-1), 0);
+ /// ```
#[stable(feature = "num_wrapping", since = "1.2.0")]
#[inline(always)]
pub fn wrapping_rem(self, rhs: Self) -> Self {
/// negative minimal value for the type); this is a positive
/// value that is too large to represent in the type. In such
/// a case, this function returns `MIN` itself.
+ ///
+ /// # Examples
+ ///
+ /// Basic usage:
+ ///
+ /// ```
+ /// assert_eq!(100i8.wrapping_neg(), -100);
+ /// assert_eq!((-128i8).wrapping_neg(), -128);
+ /// ```
#[stable(feature = "num_wrapping", since = "1.2.0")]
#[inline(always)]
pub fn wrapping_neg(self) -> Self {
/// Panic-free bitwise shift-left; yields `self << mask(rhs)`,
/// where `mask` removes any high-order bits of `rhs` that
/// would cause the shift to exceed the bitwidth of the type.
+ ///
+ /// # Examples
+ ///
+ /// Basic usage:
+ ///
+ /// ```
+ /// assert_eq!(1u8.wrapping_shl(7), 128);
+ /// assert_eq!(1u8.wrapping_shl(8), 1);
+ /// ```
#[stable(feature = "num_wrapping", since = "1.2.0")]
#[inline(always)]
pub fn wrapping_shl(self, rhs: u32) -> Self {
/// Panic-free bitwise shift-left; yields `self >> mask(rhs)`,
/// where `mask` removes any high-order bits of `rhs` that
/// would cause the shift to exceed the bitwidth of the type.
+ ///
+ /// # Examples
+ ///
+ /// Basic usage:
+ ///
+ /// ```
+ /// assert_eq!(128u8.wrapping_shr(7), 1);
+ /// assert_eq!(128u8.wrapping_shr(8), 128);
+ /// ```
#[stable(feature = "num_wrapping", since = "1.2.0")]
#[inline(always)]
pub fn wrapping_shr(self, rhs: u32) -> Self {
///
/// # Examples
///
- /// ```rust
+ /// Basic usage:
+ ///
+ /// ```
/// assert_eq!(2i32.pow(4), 16);
/// ```
#[stable(feature = "rust1", since = "1.0.0")]
}
/// Returns `true` if and only if `self == 2^k` for some `k`.
+ ///
+ /// # Examples
+ ///
+ /// Basic usage:
+ ///
+ /// ```
+ /// assert!(16u8.is_power_of_two());
+ /// assert!(!10u8.is_power_of_two());
+ /// ```
#[stable(feature = "rust1", since = "1.0.0")]
#[inline]
pub fn is_power_of_two(self) -> bool {
/// Returns the smallest power of two greater than or equal to `self`.
/// Unspecified behavior on overflow.
+ ///
+ /// # Examples
+ ///
+ /// Basic usage:
+ ///
+ /// ```
+ /// assert_eq!(2u8.next_power_of_two(), 2);
+ /// assert_eq!(3u8.next_power_of_two(), 4);
+ /// ```
#[stable(feature = "rust1", since = "1.0.0")]
#[inline]
pub fn next_power_of_two(self) -> Self {
/// Returns the smallest power of two greater than or equal to `n`. If
/// the next power of two is greater than the type's maximum value,
/// `None` is returned, otherwise the power of two is wrapped in `Some`.
+ ///
+ /// # Examples
+ ///
+ /// Basic usage:
+ ///
+ /// ```
+ /// assert_eq!(2u8.checked_next_power_of_two(), Some(2));
+ /// assert_eq!(3u8.checked_next_power_of_two(), Some(4));
+ /// assert_eq!(200u8.checked_next_power_of_two(), None);
+ /// ```
#[stable(feature = "rust1", since = "1.0.0")]
pub fn checked_next_power_of_two(self) -> Option<Self> {
let npot = self.next_power_of_two();
issue = "27702")]
pub trait Float: Sized {
/// Returns the NaN value.
+ #[unstable(feature = "float_extras", reason = "needs removal",
+ issue = "27752")]
fn nan() -> Self;
/// Returns the infinite value.
+ #[unstable(feature = "float_extras", reason = "needs removal",
+ issue = "27752")]
fn infinity() -> Self;
/// Returns the negative infinite value.
+ #[unstable(feature = "float_extras", reason = "needs removal",
+ issue = "27752")]
fn neg_infinity() -> Self;
/// Returns -0.0.
+ #[unstable(feature = "float_extras", reason = "needs removal",
+ issue = "27752")]
fn neg_zero() -> Self;
/// Returns 0.0.
+ #[unstable(feature = "float_extras", reason = "needs removal",
+ issue = "27752")]
fn zero() -> Self;
/// Returns 1.0.
+ #[unstable(feature = "float_extras", reason = "needs removal",
+ issue = "27752")]
fn one() -> Self;
- /// Parses the string `s` with the radix `r` as a float.
- fn from_str_radix(s: &str, r: u32) -> Result<Self, ParseFloatError>;
/// Returns true if this value is NaN and false otherwise.
+ #[stable(feature = "core", since = "1.6.0")]
fn is_nan(self) -> bool;
/// Returns true if this value is positive infinity or negative infinity and
/// false otherwise.
+ #[stable(feature = "core", since = "1.6.0")]
fn is_infinite(self) -> bool;
/// Returns true if this number is neither infinite nor NaN.
+ #[stable(feature = "core", since = "1.6.0")]
fn is_finite(self) -> bool;
/// Returns true if this number is neither zero, infinite, denormal, or NaN.
+ #[stable(feature = "core", since = "1.6.0")]
fn is_normal(self) -> bool;
/// Returns the category that this number falls into.
+ #[stable(feature = "core", since = "1.6.0")]
fn classify(self) -> FpCategory;
/// Returns the mantissa, exponent and sign as integers, respectively.
+ #[unstable(feature = "float_extras", reason = "signature is undecided",
+ issue = "27752")]
fn integer_decode(self) -> (u64, i16, i8);
/// Computes the absolute value of `self`. Returns `Float::nan()` if the
/// number is `Float::nan()`.
+ #[stable(feature = "core", since = "1.6.0")]
fn abs(self) -> Self;
/// Returns a number that represents the sign of `self`.
///
/// - `1.0` if the number is positive, `+0.0` or `Float::infinity()`
/// - `-1.0` if the number is negative, `-0.0` or `Float::neg_infinity()`
/// - `Float::nan()` if the number is `Float::nan()`
+ #[stable(feature = "core", since = "1.6.0")]
fn signum(self) -> Self;
+
/// Returns `true` if `self` is positive, including `+0.0` and
/// `Float::infinity()`.
- fn is_positive(self) -> bool;
+ #[stable(feature = "core", since = "1.6.0")]
+ fn is_sign_positive(self) -> bool;
/// Returns `true` if `self` is negative, including `-0.0` and
/// `Float::neg_infinity()`.
- fn is_negative(self) -> bool;
+ #[stable(feature = "core", since = "1.6.0")]
+ fn is_sign_negative(self) -> bool;
/// Take the reciprocal (inverse) of a number, `1/x`.
+ #[stable(feature = "core", since = "1.6.0")]
fn recip(self) -> Self;
/// Raise a number to an integer power.
///
/// Using this function is generally faster than using `powf`
+ #[stable(feature = "core", since = "1.6.0")]
fn powi(self, n: i32) -> Self;
/// Convert radians to degrees.
+ #[unstable(feature = "float_extras", reason = "desirability is unclear",
+ issue = "27752")]
fn to_degrees(self) -> Self;
/// Convert degrees to radians.
+ #[unstable(feature = "float_extras", reason = "desirability is unclear",
+ issue = "27752")]
fn to_radians(self) -> Self;
}
}
}
+#[stable(feature = "rust1", since = "1.0.0")]
pub use num::dec2flt::ParseFloatError;
// Conversion traits for primitive integer and float types