Struct bigdecimal::BigDecimal [] [src]

pub struct BigDecimal { /* fields omitted */ }

A big decimal type.

Methods

impl BigDecimal
[src]

[src]

Creates and initializes a BigDecimal.

[src]

Creates and initializes a BigDecimal.

Examples

use bigdecimal::{BigDecimal, Zero};

assert_eq!(BigDecimal::parse_bytes(b"0", 10).unwrap(), BigDecimal::zero());
// assert_eq!(BigDecimal::parse_bytes(b"f", 16), BigDecimal::parse_bytes(b"16", 10));

[src]

Return a new BigDecimal object equivalent to self, with internal scaling set to the number specified. If the new_scale is lower than the current value (indicating a larger power of 10), digits will be dropped (as precision is lower)

[src]

Return the sign of the BigDecimal as num::bigint::Sign.

Examples

extern crate num;
extern crate bigdecimal;
use std::str::FromStr;

assert_eq!(bigdecimal::BigDecimal::from_str("-1").unwrap().sign(), num::bigint::Sign::Minus);
assert_eq!(bigdecimal::BigDecimal::from_str("0").unwrap().sign(), num::bigint::Sign::NoSign);
assert_eq!(bigdecimal::BigDecimal::from_str("1").unwrap().sign(), num::bigint::Sign::Plus);

[src]

Return the internal big integer value and an exponent. Note that a positive exponent indicates a negative power of 10.

Examples

extern crate num;
extern crate bigdecimal;
use std::str::FromStr;

assert_eq!(bigdecimal::BigDecimal::from_str("1.1").unwrap().as_bigint_and_exponent(),
           (num::bigint::BigInt::from_str("11").unwrap(), 1));

[src]

Convert into the internal big integer value and an exponent. Note that a positive exponent indicates a negative power of 10.

Examples

extern crate num;
extern crate bigdecimal;
use std::str::FromStr;

assert_eq!(bigdecimal::BigDecimal::from_str("1.1").unwrap().into_bigint_and_exponent(),
           (num::bigint::BigInt::from_str("11").unwrap(), 1));

[src]

Compute the absolute value of number

Trait Implementations

impl Clone for BigDecimal
[src]

[src]

Returns a copy of the value. Read more

1.0.0
[src]

Performs copy-assignment from source. Read more

impl Debug for BigDecimal
[src]

[src]

Formats the value using the given formatter. Read more

impl Eq for BigDecimal
[src]

impl FromStr for BigDecimal
[src]

The associated error which can be returned from parsing.

[src]

Parses a string s to return a value of this type. Read more

impl Hash for BigDecimal
[src]

[src]

Feeds this value into the given [Hasher]. Read more

1.3.0
[src]

Feeds a slice of this type into the given [Hasher]. Read more

impl PartialOrd for BigDecimal
[src]

[src]

This method returns an ordering between self and other values if one exists. Read more

1.0.0
[src]

This method tests less than (for self and other) and is used by the < operator. Read more

1.0.0
[src]

This method tests less than or equal to (for self and other) and is used by the <= operator. Read more

1.0.0
[src]

This method tests greater than (for self and other) and is used by the > operator. Read more

1.0.0
[src]

This method tests greater than or equal to (for self and other) and is used by the >= operator. Read more

impl Ord for BigDecimal
[src]

[src]

Complete ordering implementation for BigDecimal

Example

use std::str::FromStr;

let a = bigdecimal::BigDecimal::from_str("-1").unwrap();
let b = bigdecimal::BigDecimal::from_str("1").unwrap();
assert!(a < b);
assert!(b > a);
let c = bigdecimal::BigDecimal::from_str("1").unwrap();
assert!(b >= c);
assert!(c >= b);
let d = bigdecimal::BigDecimal::from_str("10.0").unwrap();
assert!(d > c);
let e = bigdecimal::BigDecimal::from_str(".5").unwrap();
assert!(e < c);

1.21.0
[src]

Compares and returns the maximum of two values. Read more

1.21.0
[src]

Compares and returns the minimum of two values. Read more

impl PartialEq for BigDecimal
[src]

[src]

This method tests for self and other values to be equal, and is used by ==. Read more

1.0.0
[src]

This method tests for !=.

impl Default for BigDecimal
[src]

[src]

Returns the "default value" for a type. Read more

impl Zero for BigDecimal
[src]

[src]

Returns the additive identity element of Self, 0. Read more

[src]

Returns true if self is equal to the additive identity.

impl One for BigDecimal
[src]

[src]

Returns the multiplicative identity element of Self, 1. Read more

[src]

Returns true if self is equal to the multiplicative identity. Read more

impl Add<BigDecimal> for BigDecimal
[src]

The resulting type after applying the + operator.

[src]

Performs the + operation.

impl<'a> Add<&'a BigDecimal> for BigDecimal
[src]

The resulting type after applying the + operator.

[src]

Performs the + operation.

impl<'a> Add<BigDecimal> for &'a BigDecimal
[src]

The resulting type after applying the + operator.

[src]

Performs the + operation.

impl<'a, 'b> Add<&'b BigDecimal> for &'a BigDecimal
[src]

The resulting type after applying the + operator.

[src]

Performs the + operation.

impl AddAssign<BigDecimal> for BigDecimal
[src]

[src]

Performs the += operation.

impl<'a> AddAssign<&'a BigDecimal> for BigDecimal
[src]

[src]

Performs the += operation.

impl Sub<BigDecimal> for BigDecimal
[src]

The resulting type after applying the - operator.

[src]

Performs the - operation.

impl<'a> Sub<&'a BigDecimal> for BigDecimal
[src]

The resulting type after applying the - operator.

[src]

Performs the - operation.

impl<'a> Sub<BigDecimal> for &'a BigDecimal
[src]

The resulting type after applying the - operator.

[src]

Performs the - operation.

impl<'a, 'b> Sub<&'b BigDecimal> for &'a BigDecimal
[src]

The resulting type after applying the - operator.

[src]

Performs the - operation.

impl SubAssign<BigDecimal> for BigDecimal
[src]

[src]

Performs the -= operation.

impl<'a> SubAssign<&'a BigDecimal> for BigDecimal
[src]

[src]

Performs the -= operation.

impl Mul<BigDecimal> for BigDecimal
[src]

The resulting type after applying the * operator.

[src]

Performs the * operation.

impl<'a> Mul<&'a BigDecimal> for BigDecimal
[src]

The resulting type after applying the * operator.

[src]

Performs the * operation.

impl<'a> Mul<BigDecimal> for &'a BigDecimal
[src]

The resulting type after applying the * operator.

[src]

Performs the * operation.

impl<'a, 'b> Mul<&'b BigDecimal> for &'a BigDecimal
[src]

The resulting type after applying the * operator.

[src]

Performs the * operation.

impl MulAssign<BigDecimal> for BigDecimal
[src]

[src]

Performs the *= operation.

impl<'a> MulAssign<&'a BigDecimal> for BigDecimal
[src]

[src]

Performs the *= operation.

impl Div<BigDecimal> for BigDecimal
[src]

The resulting type after applying the / operator.

[src]

Performs the / operation.

impl<'a> Div<&'a BigDecimal> for BigDecimal
[src]

The resulting type after applying the / operator.

[src]

Performs the / operation.

impl<'a> Div<BigDecimal> for &'a BigDecimal
[src]

The resulting type after applying the / operator.

[src]

Performs the / operation.

impl<'a, 'b> Div<&'b BigDecimal> for &'a BigDecimal
[src]

The resulting type after applying the / operator.

[src]

Performs the / operation.

impl Rem<BigDecimal> for BigDecimal
[src]

The resulting type after applying the % operator.

[src]

Performs the % operation.

impl<'a> Rem<&'a BigDecimal> for BigDecimal
[src]

The resulting type after applying the % operator.

[src]

Performs the % operation.

impl<'a> Rem<BigDecimal> for &'a BigDecimal
[src]

The resulting type after applying the % operator.

[src]

Performs the % operation.

impl<'a, 'b> Rem<&'b BigDecimal> for &'a BigDecimal
[src]

The resulting type after applying the % operator.

[src]

Performs the % operation.

impl Neg for BigDecimal
[src]

The resulting type after applying the - operator.

[src]

Performs the unary - operation.

impl<'a> Neg for &'a BigDecimal
[src]

The resulting type after applying the - operator.

[src]

Performs the unary - operation.

impl Signed for BigDecimal
[src]

[src]

Computes the absolute value. Read more

[src]

The positive difference of two numbers. Read more

[src]

Returns the sign of the number. Read more

[src]

Returns true if the number is positive and false if the number is zero or negative.

[src]

Returns true if the number is negative and false if the number is zero or positive.

impl Display for BigDecimal
[src]

[src]

Formats the value using the given formatter. Read more

impl Num for BigDecimal
[src]

[src]

Creates and initializes a BigDecimal.

impl ToPrimitive for BigDecimal
[src]

[src]

Converts the value of self to an i64.

[src]

Converts the value of self to an u64.

[src]

Converts the value of self to an f64.

[src]

Converts the value of self to an isize.

[src]

Converts the value of self to an i8.

[src]

Converts the value of self to an i16.

[src]

Converts the value of self to an i32.

[src]

Converts the value of self to a usize.

[src]

Converts the value of self to an u8.

[src]

Converts the value of self to an u16.

[src]

Converts the value of self to an u32.

[src]

Converts the value of self to an f32.

impl From<i64> for BigDecimal
[src]

[src]

Performs the conversion.

impl From<u64> for BigDecimal
[src]

[src]

Performs the conversion.

impl From<(BigInt, i64)> for BigDecimal
[src]

[src]

Performs the conversion.

impl From<u8> for BigDecimal
[src]

[src]

Performs the conversion.

impl From<u16> for BigDecimal
[src]

[src]

Performs the conversion.

impl From<u32> for BigDecimal
[src]

[src]

Performs the conversion.

impl From<i8> for BigDecimal
[src]

[src]

Performs the conversion.

impl From<i16> for BigDecimal
[src]

[src]

Performs the conversion.

impl From<i32> for BigDecimal
[src]

[src]

Performs the conversion.

impl From<f32> for BigDecimal
[src]

[src]

Performs the conversion.

impl From<f64> for BigDecimal
[src]

[src]

Performs the conversion.

impl FromPrimitive for BigDecimal
[src]

[src]

Convert an i64 to return an optional value of this type. If the type cannot be represented by this value, the None is returned. Read more

[src]

Convert an u64 to return an optional value of this type. If the type cannot be represented by this value, the None is returned. Read more

[src]

Convert a f32 to return an optional value of this type. If the type cannot be represented by this value, the None is returned. Read more

[src]

Convert a f64 to return an optional value of this type. If the type cannot be represented by this value, the None is returned. Read more

[src]

Convert an isize to return an optional value of this type. If the value cannot be represented by this value, the None is returned. Read more

[src]

Convert an i8 to return an optional value of this type. If the type cannot be represented by this value, the None is returned. Read more

[src]

Convert an i16 to return an optional value of this type. If the type cannot be represented by this value, the None is returned. Read more

[src]

Convert an i32 to return an optional value of this type. If the type cannot be represented by this value, the None is returned. Read more

[src]

Convert a usize to return an optional value of this type. If the type cannot be represented by this value, the None is returned. Read more

[src]

Convert an u8 to return an optional value of this type. If the type cannot be represented by this value, the None is returned. Read more

[src]

Convert an u16 to return an optional value of this type. If the type cannot be represented by this value, the None is returned. Read more

[src]

Convert an u32 to return an optional value of this type. If the type cannot be represented by this value, the None is returned. Read more

impl ToBigInt for BigDecimal
[src]

[src]

Converts the value of self to a BigInt.

Auto Trait Implementations

impl Send for BigDecimal

impl Sync for BigDecimal