Struct rust_decimal::Decimal [] [src]

pub struct Decimal { /* fields omitted */ }

Decimal represents a 128 bit representation of a fixed-precision decimal number. The finite set of values of type Decimal are of the form m / 10e, where m is an integer such that -296 <= m <= 296, and e is an integer between 0 and 28 inclusive.

Methods

impl Decimal
[src]

[src]

Returns a Decimal with a 64 bit m representation and corresponding e scale.

Arguments

  • num - An i64 that represents the m portion of the decimal number
  • scale - A u32 representing the e portion of the decimal number.

Example

use rust_decimal::Decimal;
let pi = Decimal::new(3141i64, 3u32);

[src]

Returns the scale of the decimal number, otherwise known as e.

[src]

An optimized method for changing the sign of a decimal number.

Arguments

  • positive: true if the resulting decimal should be positive.

[src]

Returns a serialized version of the decimal number. The resulting byte array will have the following representation:

  • Bytes 1-4: flags
  • Bytes 5-8: lo portion of m
  • Bytes 9-12: mid portion of m
  • Bytes 13-16: high portion of m

[src]

Deserializes the given bytes into a decimal number. The deserialized byte representation must be 16 bytes and adhere to the followign convention:

  • Bytes 1-4: flags
  • Bytes 5-8: lo portion of m
  • Bytes 9-12: mid portion of m
  • Bytes 13-16: high portion of m

[src]

Returns true if the decimal is negative.

[src]

Returns true if the decimal is positive.

[src]

Returns the minimum possible number that Decimal can represent.

[src]

Returns the maximum possible number that Decimal can represent.

[src]

Returns a new Decimal number with no fractional portion (i.e. an integer). Rounding currently follows "Bankers Rounding" rules. e.g. 6.5 -> 6, 7.5 -> 8

[src]

Returns a new Decimal number with the specified number of decimal points for fractional portion. Rounding currently follows "Bankers Rounding" rules. e.g. 6.5 -> 6, 7.5 -> 8

Arguments

  • dp: the number of decimal points to round to.

Trait Implementations

impl Clone for Decimal
[src]

[src]

Returns a copy of the value. Read more

1.0.0
[src]

Performs copy-assignment from source. Read more

impl Debug for Decimal
[src]

[src]

Formats the value using the given formatter.

impl Copy for Decimal
[src]

impl From<isize> for Decimal
[src]

[src]

Performs the conversion.

impl From<i8> for Decimal
[src]

[src]

Performs the conversion.

impl From<i16> for Decimal
[src]

[src]

Performs the conversion.

impl From<i32> for Decimal
[src]

[src]

Performs the conversion.

impl From<i64> for Decimal
[src]

[src]

Performs the conversion.

impl From<usize> for Decimal
[src]

[src]

Performs the conversion.

impl From<u8> for Decimal
[src]

[src]

Performs the conversion.

impl From<u16> for Decimal
[src]

[src]

Performs the conversion.

impl From<u32> for Decimal
[src]

[src]

Performs the conversion.

impl From<u64> for Decimal
[src]

[src]

Performs the conversion.

impl Zero for Decimal
[src]

[src]

Returns true if self is equal to the additive identity.

[src]

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

impl One for Decimal
[src]

[src]

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

impl FromStr for Decimal
[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 FromPrimitive for Decimal
[src]

[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 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 u32 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 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 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 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

impl ToPrimitive for Decimal
[src]

[src]

Converts the value of self to an f64.

[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 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 Display for Decimal
[src]

[src]

Formats the value using the given formatter. Read more

impl Add<Decimal> for Decimal
[src]

The resulting type after applying the + operator.

[src]

Performs the + operation.

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

The resulting type after applying the + operator.

[src]

Performs the + operation.

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

The resulting type after applying the + operator.

[src]

Performs the + operation.

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

The resulting type after applying the + operator.

[src]

Performs the + operation.

impl Sub<Decimal> for Decimal
[src]

The resulting type after applying the - operator.

[src]

Performs the - operation.

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

The resulting type after applying the - operator.

[src]

Performs the - operation.

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

The resulting type after applying the - operator.

[src]

Performs the - operation.

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

The resulting type after applying the - operator.

[src]

Performs the - operation.

impl Mul<Decimal> for Decimal
[src]

The resulting type after applying the * operator.

[src]

Performs the * operation.

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

The resulting type after applying the * operator.

[src]

Performs the * operation.

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

The resulting type after applying the * operator.

[src]

Performs the * operation.

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

The resulting type after applying the * operator.

[src]

Performs the * operation.

impl Div<Decimal> for Decimal
[src]

The resulting type after applying the / operator.

[src]

Performs the / operation.

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

The resulting type after applying the / operator.

[src]

Performs the / operation.

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

The resulting type after applying the / operator.

[src]

Performs the / operation.

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

The resulting type after applying the / operator.

[src]

Performs the / operation.

impl Rem<Decimal> for Decimal
[src]

The resulting type after applying the % operator.

[src]

Performs the % operation.

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

The resulting type after applying the % operator.

[src]

Performs the % operation.

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

The resulting type after applying the % operator.

[src]

Performs the % operation.

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

The resulting type after applying the % operator.

[src]

Performs the % operation.

impl PartialEq for Decimal
[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 Eq for Decimal
[src]

impl PartialOrd for Decimal
[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 Decimal
[src]

[src]

This method returns an Ordering between self and other. Read more

1.22.0
[src]

Compares and returns the maximum of two values. Read more

1.22.0
[src]

Compares and returns the minimum of two values. Read more

impl FromSql for Decimal
[src]

[src]

Creates a new value of this type from a buffer of data of the specified Postgres Type in its binary format. Read more

[src]

Determines if a value of this type can be created from the specified Postgres Type. Read more

Creates a new value of this type from a NULL SQL value. Read more

A convenience function that delegates to from_sql and from_sql_null depending on the value of raw. Read more

impl ToSql for Decimal
[src]

[src]

Converts the value of self into the binary format of the specified Postgres Type, appending it to out. Read more

[src]

Determines if a value of this type can be converted to the specified Postgres Type. Read more

An adaptor method used internally by Rust-Postgres. Read more

impl<'de> Deserialize<'de> for Decimal
[src]

[src]

Deserialize this value from the given Serde deserializer. Read more

impl Serialize for Decimal
[src]

[src]

Serialize this value into the given Serde serializer. Read more