Merge pull request #121 from wrieger93/issue_120

Add a function that returns the sign of a BigInt.
This commit is contained in:
Josh Stone 2015-10-27 12:13:17 -07:00
commit 642787fbd2
1 changed files with 16 additions and 0 deletions

View File

@ -1779,6 +1779,22 @@ impl BigInt {
(self.sign, self.data.to_bytes_be())
}
/// Returns the sign of the `BigInt` as a `Sign`.
///
/// # Examples
///
/// ```
/// use num::bigint::{ToBigInt, Sign};
///
/// assert_eq!(ToBigInt::to_bigint(&1234).unwrap().sign(), Sign::Plus);
/// assert_eq!(ToBigInt::to_bigint(&-4321).unwrap().sign(), Sign::Minus);
/// assert_eq!(ToBigInt::to_bigint(&0).unwrap().sign(), Sign::NoSign);
/// ```
#[inline]
pub fn sign(&self) -> Sign {
self.sign
}
/// Creates and initializes a `BigInt`.
///
/// # Examples