pub struct BigDecimal { /* private fields */ }
Expand description
A big decimal type.
Implementationsยง
Sourceยงimpl BigDecimal
impl BigDecimal
Sourcepub fn new(digits: BigInt, scale: i64) -> BigDecimal
pub fn new(digits: BigInt, scale: i64) -> BigDecimal
Creates and initializes a BigDecimal
.
Sourcepub fn parse_bytes(buf: &[u8], radix: u32) -> Option<BigDecimal>
pub fn parse_bytes(buf: &[u8], radix: u32) -> Option<BigDecimal>
Creates and initializes a BigDecimal
.
Decodes using str::from_utf8
and forwards to BigDecimal::from_str_radix
.
Only base-10 is supported.
ยงExamples
use bigdecimal::{BigDecimal, Zero};
assert_eq!(BigDecimal::parse_bytes(b"0", 10).unwrap(), BigDecimal::zero());
assert_eq!(BigDecimal::parse_bytes(b"13", 10).unwrap(), BigDecimal::from(13));
Sourcepub fn with_scale(&self, new_scale: i64) -> BigDecimal
pub fn with_scale(&self, new_scale: i64) -> BigDecimal
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)
Sourcepub fn with_prec(&self, prec: u64) -> BigDecimal
pub fn with_prec(&self, prec: u64) -> BigDecimal
Return a new BigDecimal object with precision set to new value
Sourcepub fn sign(&self) -> Sign
pub fn sign(&self) -> Sign
Return the sign of the BigDecimal
as num::bigint::Sign
.
ยงExamples
extern crate num_bigint;
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);
Sourcepub fn as_bigint_and_exponent(&self) -> (BigInt, i64)
pub fn as_bigint_and_exponent(&self) -> (BigInt, i64)
Return the internal big integer value and an exponent. Note that a positive exponent indicates a negative power of 10.
ยงExamples
extern crate num_bigint;
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));
Sourcepub fn into_bigint_and_exponent(self) -> (BigInt, i64)
pub fn into_bigint_and_exponent(self) -> (BigInt, i64)
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_bigint;
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));
Sourcepub fn abs(&self) -> BigDecimal
pub fn abs(&self) -> BigDecimal
Compute the absolute value of number
pub fn double(&self) -> BigDecimal
Sourcepub fn half(&self) -> BigDecimal
pub fn half(&self) -> BigDecimal
Divide this efficiently by 2
Note, if this is odd, the precision will increase by 1, regardless of the contextโs limit.
Sourcepub fn square(&self) -> BigDecimal
pub fn square(&self) -> BigDecimal
pub fn cube(&self) -> BigDecimal
Sourcepub fn sqrt(&self) -> Option<BigDecimal>
pub fn sqrt(&self) -> Option<BigDecimal>
Take the square root of the number
If the value is < 0, None is returned
Sourcepub fn cbrt(&self) -> BigDecimal
pub fn cbrt(&self) -> BigDecimal
Take the cube root of the number
Sourcepub fn inverse(&self) -> BigDecimal
pub fn inverse(&self) -> BigDecimal
Compute the reciprical of the number: x-1
Sourcepub fn round(&self, round_digits: i64) -> BigDecimal
pub fn round(&self, round_digits: i64) -> BigDecimal
Return number rounded to round_digits precision after the decimal point
Sourcepub fn is_integer(&self) -> bool
pub fn is_integer(&self) -> bool
Return true if this number has zero fractional part (is equal to an integer)
Sourcepub fn exp(&self) -> BigDecimal
pub fn exp(&self) -> BigDecimal
Evaluate the natural-exponential function ex
pub fn normalized(&self) -> BigDecimal
Trait Implementationsยง
Sourceยงimpl<'a, 'b> Add<&'b BigDecimal> for &'a BigDecimal
impl<'a, 'b> Add<&'b BigDecimal> for &'a BigDecimal
Sourceยงtype Output = BigDecimal
type Output = BigDecimal
+
operator.Sourceยงfn add(self, rhs: &BigDecimal) -> BigDecimal
fn add(self, rhs: &BigDecimal) -> BigDecimal
+
operation. Read moreSourceยงimpl<'a> Add<&'a BigDecimal> for BigDecimal
impl<'a> Add<&'a BigDecimal> for BigDecimal
Sourceยงtype Output = BigDecimal
type Output = BigDecimal
+
operator.Sourceยงfn add(self, rhs: &'a BigDecimal) -> BigDecimal
fn add(self, rhs: &'a BigDecimal) -> BigDecimal
+
operation. Read moreSourceยงimpl<'a, 'b> Add<&'a BigInt> for &'b BigDecimal
impl<'a, 'b> Add<&'a BigInt> for &'b BigDecimal
Sourceยงtype Output = BigDecimal
type Output = BigDecimal
+
operator.Sourceยงimpl<'a> Add<&'a BigInt> for BigDecimal
impl<'a> Add<&'a BigInt> for BigDecimal
Sourceยงtype Output = BigDecimal
type Output = BigDecimal
+
operator.Sourceยงimpl<'a> Add<BigDecimal> for &'a BigDecimal
impl<'a> Add<BigDecimal> for &'a BigDecimal
Sourceยงtype Output = BigDecimal
type Output = BigDecimal
+
operator.Sourceยงfn add(self, rhs: BigDecimal) -> BigDecimal
fn add(self, rhs: BigDecimal) -> BigDecimal
+
operation. Read moreSourceยงimpl<'a> Add<BigInt> for &'a BigDecimal
impl<'a> Add<BigInt> for &'a BigDecimal
Sourceยงtype Output = BigDecimal
type Output = BigDecimal
+
operator.Sourceยงimpl Add<BigInt> for BigDecimal
impl Add<BigInt> for BigDecimal
Sourceยงtype Output = BigDecimal
type Output = BigDecimal
+
operator.Sourceยงimpl Add for BigDecimal
impl Add for BigDecimal
Sourceยงtype Output = BigDecimal
type Output = BigDecimal
+
operator.Sourceยงfn add(self, rhs: BigDecimal) -> BigDecimal
fn add(self, rhs: BigDecimal) -> BigDecimal
+
operation. Read moreSourceยงimpl<'a> AddAssign<&'a BigDecimal> for BigDecimal
impl<'a> AddAssign<&'a BigDecimal> for BigDecimal
Sourceยงfn add_assign(&mut self, rhs: &BigDecimal)
fn add_assign(&mut self, rhs: &BigDecimal)
+=
operation. Read moreSourceยงimpl<'a> AddAssign<&'a BigInt> for BigDecimal
impl<'a> AddAssign<&'a BigInt> for BigDecimal
Sourceยงfn add_assign(&mut self, rhs: &BigInt)
fn add_assign(&mut self, rhs: &BigInt)
+=
operation. Read moreSourceยงimpl<'a> AddAssign<BigInt> for BigDecimal
impl<'a> AddAssign<BigInt> for BigDecimal
Sourceยงfn add_assign(&mut self, rhs: BigInt)
fn add_assign(&mut self, rhs: BigInt)
+=
operation. Read moreSourceยงimpl AddAssign for BigDecimal
impl AddAssign for BigDecimal
Sourceยงfn add_assign(&mut self, other: BigDecimal)
fn add_assign(&mut self, other: BigDecimal)
+=
operation. Read moreSourceยงimpl Clone for BigDecimal
impl Clone for BigDecimal
Sourceยงfn clone(&self) -> BigDecimal
fn clone(&self) -> BigDecimal
1.0.0 ยท Sourceยงfn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
source
. Read moreSourceยงimpl Debug for BigDecimal
impl Debug for BigDecimal
Sourceยงimpl Decode<'_, Postgres> for BigDecimal
ยงNote: NaN
BigDecimal
has a greater range than NUMERIC
(see the corresponding Encode
impl for details)
but cannot represent NaN
, so decoding may return an error.
impl Decode<'_, Postgres> for BigDecimal
ยงNote: NaN
BigDecimal
has a greater range than NUMERIC
(see the corresponding Encode
impl for details)
but cannot represent NaN
, so decoding may return an error.
Sourceยงfn decode(
value: PgValueRef<'_>,
) -> Result<BigDecimal, Box<dyn Error + Sync + Send>>
fn decode( value: PgValueRef<'_>, ) -> Result<BigDecimal, Box<dyn Error + Sync + Send>>
Sourceยงimpl Default for BigDecimal
impl Default for BigDecimal
Sourceยงfn default() -> BigDecimal
fn default() -> BigDecimal
Sourceยงimpl Display for BigDecimal
impl Display for BigDecimal
Sourceยงimpl<'a, 'b> Div<&'b BigDecimal> for &'a BigDecimal
impl<'a, 'b> Div<&'b BigDecimal> for &'a BigDecimal
Sourceยงtype Output = BigDecimal
type Output = BigDecimal
/
operator.Sourceยงfn div(self, other: &BigDecimal) -> BigDecimal
fn div(self, other: &BigDecimal) -> BigDecimal
/
operation. Read moreSourceยงimpl<'a> Div<&'a BigDecimal> for BigDecimal
impl<'a> Div<&'a BigDecimal> for BigDecimal
Sourceยงtype Output = BigDecimal
type Output = BigDecimal
/
operator.Sourceยงfn div(self, other: &'a BigDecimal) -> BigDecimal
fn div(self, other: &'a BigDecimal) -> BigDecimal
/
operation. Read moreSourceยงimpl<'a> Div<BigDecimal> for &'a BigDecimal
impl<'a> Div<BigDecimal> for &'a BigDecimal
Sourceยงtype Output = BigDecimal
type Output = BigDecimal
/
operator.Sourceยงfn div(self, other: BigDecimal) -> BigDecimal
fn div(self, other: BigDecimal) -> BigDecimal
/
operation. Read moreSourceยงimpl<'a> Div<f32> for &'a BigDecimal
impl<'a> Div<f32> for &'a BigDecimal
Sourceยงimpl<'a> Div<f64> for &'a BigDecimal
impl<'a> Div<f64> for &'a BigDecimal
Sourceยงimpl<'a> Div<i16> for &'a BigDecimal
impl<'a> Div<i16> for &'a BigDecimal
Sourceยงimpl<'a> Div<i16> for BigDecimal
impl<'a> Div<i16> for BigDecimal
Sourceยงimpl<'a> Div<i32> for &'a BigDecimal
impl<'a> Div<i32> for &'a BigDecimal
Sourceยงimpl<'a> Div<i32> for BigDecimal
impl<'a> Div<i32> for BigDecimal
Sourceยงimpl<'a> Div<i64> for &'a BigDecimal
impl<'a> Div<i64> for &'a BigDecimal
Sourceยงimpl<'a> Div<i64> for BigDecimal
impl<'a> Div<i64> for BigDecimal
Sourceยงimpl<'a> Div<i8> for &'a BigDecimal
impl<'a> Div<i8> for &'a BigDecimal
Sourceยงimpl<'a> Div<i8> for BigDecimal
impl<'a> Div<i8> for BigDecimal
Sourceยงimpl<'a> Div<u16> for &'a BigDecimal
impl<'a> Div<u16> for &'a BigDecimal
Sourceยงimpl<'a> Div<u32> for &'a BigDecimal
impl<'a> Div<u32> for &'a BigDecimal
Sourceยงimpl<'a> Div<u64> for &'a BigDecimal
impl<'a> Div<u64> for &'a BigDecimal
Sourceยงimpl<'a> Div<u8> for &'a BigDecimal
impl<'a> Div<u8> for &'a BigDecimal
Sourceยงimpl Div for BigDecimal
impl Div for BigDecimal
Sourceยงtype Output = BigDecimal
type Output = BigDecimal
/
operator.Sourceยงfn div(self, other: BigDecimal) -> BigDecimal
fn div(self, other: BigDecimal) -> BigDecimal
/
operation. Read moreSourceยงimpl Encode<'_, Postgres> for BigDecimal
ยงNote: BigDecimal
Has a Larger Range than NUMERIC
BigDecimal
can represent values with a far, far greater range than the NUMERIC
type in Postgres can.
impl Encode<'_, Postgres> for BigDecimal
ยงNote: BigDecimal
Has a Larger Range than NUMERIC
BigDecimal
can represent values with a far, far greater range than the NUMERIC
type in Postgres can.
NUMERIC
is limited to 131,072 digits before the decimal point, and 16,384 digits after it.
See Section 8.1, Numeric Types of the Postgres manual for details.
Meanwhile, BigDecimal
can theoretically represent a value with an arbitrary number of decimal digits, albeit
with a maximum of 263 significant figures.
Because encoding in the current API design must be infallible,
when attempting to encode a BigDecimal
that cannot fit in the wire representation of NUMERIC
,
SQLx may instead encode a sentinel value that falls outside the allowed range but is still representable.
This will cause the query to return a DatabaseError
with code 22P03
(invalid_binary_representation
)
and the error message invalid scale in external "numeric" value
(though this may be subject to change).
However, BigDecimal
should be able to decode any NUMERIC
value except NaN
,
for which it has no representation.
Sourceยงfn encode_by_ref(&self, buf: &mut PgArgumentBuffer) -> IsNull
fn encode_by_ref(&self, buf: &mut PgArgumentBuffer) -> IsNull
fn size_hint(&self) -> usize
Sourceยงfn encode(self, buf: &mut <DB as HasArguments<'q>>::ArgumentBuffer) -> IsNullwhere
Self: Sized,
fn encode(self, buf: &mut <DB as HasArguments<'q>>::ArgumentBuffer) -> IsNullwhere
Self: Sized,
self
into buf
in the expected format for the database.fn produces(&self) -> Option<<DB as Database>::TypeInfo>
Sourceยงimpl From<BigInt> for BigDecimal
impl From<BigInt> for BigDecimal
Sourceยงfn from(int_val: BigInt) -> BigDecimal
fn from(int_val: BigInt) -> BigDecimal
Sourceยงimpl From<i16> for BigDecimal
impl From<i16> for BigDecimal
Sourceยงfn from(n: i16) -> BigDecimal
fn from(n: i16) -> BigDecimal
Sourceยงimpl From<i32> for BigDecimal
impl From<i32> for BigDecimal
Sourceยงfn from(n: i32) -> BigDecimal
fn from(n: i32) -> BigDecimal
Sourceยงimpl From<i64> for BigDecimal
impl From<i64> for BigDecimal
Sourceยงfn from(n: i64) -> BigDecimal
fn from(n: i64) -> BigDecimal
Sourceยงimpl From<i8> for BigDecimal
impl From<i8> for BigDecimal
Sourceยงfn from(n: i8) -> BigDecimal
fn from(n: i8) -> BigDecimal
Sourceยงimpl From<u16> for BigDecimal
impl From<u16> for BigDecimal
Sourceยงfn from(n: u16) -> BigDecimal
fn from(n: u16) -> BigDecimal
Sourceยงimpl From<u32> for BigDecimal
impl From<u32> for BigDecimal
Sourceยงfn from(n: u32) -> BigDecimal
fn from(n: u32) -> BigDecimal
Sourceยงimpl From<u64> for BigDecimal
impl From<u64> for BigDecimal
Sourceยงfn from(n: u64) -> BigDecimal
fn from(n: u64) -> BigDecimal
Sourceยงimpl From<u8> for BigDecimal
impl From<u8> for BigDecimal
Sourceยงfn from(n: u8) -> BigDecimal
fn from(n: u8) -> BigDecimal
Sourceยงimpl FromPrimitive for BigDecimal
impl FromPrimitive for BigDecimal
Sourceยงfn from_i64(n: i64) -> Option<BigDecimal>
fn from_i64(n: i64) -> Option<BigDecimal>
i64
to return an optional value of this type. If the
value cannot be represented by this type, then None
is returned.Sourceยงfn from_u64(n: u64) -> Option<BigDecimal>
fn from_u64(n: u64) -> Option<BigDecimal>
u64
to return an optional value of this type. If the
value cannot be represented by this type, then None
is returned.Sourceยงfn from_f32(n: f32) -> Option<BigDecimal>
fn from_f32(n: f32) -> Option<BigDecimal>
f32
to return an optional value of this type. If the
value cannot be represented by this type, then None
is returned.Sourceยงfn from_f64(n: f64) -> Option<BigDecimal>
fn from_f64(n: f64) -> Option<BigDecimal>
f64
to return an optional value of this type. If the
value cannot be represented by this type, then None
is returned. Read moreSourceยงfn from_isize(n: isize) -> Option<Self>
fn from_isize(n: isize) -> Option<Self>
isize
to return an optional value of this type. If the
value cannot be represented by this type, then None
is returned.Sourceยงfn from_i8(n: i8) -> Option<Self>
fn from_i8(n: i8) -> Option<Self>
i8
to return an optional value of this type. If the
value cannot be represented by this type, then None
is returned.Sourceยงfn from_i16(n: i16) -> Option<Self>
fn from_i16(n: i16) -> Option<Self>
i16
to return an optional value of this type. If the
value cannot be represented by this type, then None
is returned.Sourceยงfn from_i32(n: i32) -> Option<Self>
fn from_i32(n: i32) -> Option<Self>
i32
to return an optional value of this type. If the
value cannot be represented by this type, then None
is returned.Sourceยงfn from_i128(n: i128) -> Option<Self>
fn from_i128(n: i128) -> Option<Self>
i128
to return an optional value of this type. If the
value cannot be represented by this type, then None
is returned. Read moreSourceยงfn from_usize(n: usize) -> Option<Self>
fn from_usize(n: usize) -> Option<Self>
usize
to return an optional value of this type. If the
value cannot be represented by this type, then None
is returned.Sourceยงfn from_u8(n: u8) -> Option<Self>
fn from_u8(n: u8) -> Option<Self>
u8
to return an optional value of this type. If the
value cannot be represented by this type, then None
is returned.Sourceยงfn from_u16(n: u16) -> Option<Self>
fn from_u16(n: u16) -> Option<Self>
u16
to return an optional value of this type. If the
value cannot be represented by this type, then None
is returned.Sourceยงimpl FromStr for BigDecimal
impl FromStr for BigDecimal
Sourceยงtype Err = ParseBigDecimalError
type Err = ParseBigDecimalError
Sourceยงfn from_str(s: &str) -> Result<BigDecimal, ParseBigDecimalError>
fn from_str(s: &str) -> Result<BigDecimal, ParseBigDecimalError>
s
to return a value of this type. Read moreSourceยงimpl Hash for BigDecimal
impl Hash for BigDecimal
Sourceยงimpl<'a, 'b> Mul<&'b BigDecimal> for &'a BigDecimal
impl<'a, 'b> Mul<&'b BigDecimal> for &'a BigDecimal
Sourceยงtype Output = BigDecimal
type Output = BigDecimal
*
operator.Sourceยงfn mul(self, rhs: &BigDecimal) -> BigDecimal
fn mul(self, rhs: &BigDecimal) -> BigDecimal
*
operation. Read moreSourceยงimpl<'a> Mul<&'a BigDecimal> for BigDecimal
impl<'a> Mul<&'a BigDecimal> for BigDecimal
Sourceยงtype Output = BigDecimal
type Output = BigDecimal
*
operator.Sourceยงfn mul(self, rhs: &'a BigDecimal) -> BigDecimal
fn mul(self, rhs: &'a BigDecimal) -> BigDecimal
*
operation. Read moreSourceยงimpl<'a, 'b> Mul<&'a BigInt> for &'b BigDecimal
impl<'a, 'b> Mul<&'a BigInt> for &'b BigDecimal
Sourceยงtype Output = BigDecimal
type Output = BigDecimal
*
operator.Sourceยงimpl<'a> Mul<&'a BigInt> for BigDecimal
impl<'a> Mul<&'a BigInt> for BigDecimal
Sourceยงtype Output = BigDecimal
type Output = BigDecimal
*
operator.Sourceยงimpl<'a> Mul<BigDecimal> for &'a BigDecimal
impl<'a> Mul<BigDecimal> for &'a BigDecimal
Sourceยงtype Output = BigDecimal
type Output = BigDecimal
*
operator.Sourceยงfn mul(self, rhs: BigDecimal) -> BigDecimal
fn mul(self, rhs: BigDecimal) -> BigDecimal
*
operation. Read moreSourceยงimpl<'a> Mul<BigInt> for &'a BigDecimal
impl<'a> Mul<BigInt> for &'a BigDecimal
Sourceยงtype Output = BigDecimal
type Output = BigDecimal
*
operator.Sourceยงimpl Mul<BigInt> for BigDecimal
impl Mul<BigInt> for BigDecimal
Sourceยงtype Output = BigDecimal
type Output = BigDecimal
*
operator.Sourceยงimpl Mul for BigDecimal
impl Mul for BigDecimal
Sourceยงtype Output = BigDecimal
type Output = BigDecimal
*
operator.Sourceยงfn mul(self, rhs: BigDecimal) -> BigDecimal
fn mul(self, rhs: BigDecimal) -> BigDecimal
*
operation. Read moreSourceยงimpl<'a> MulAssign<&'a BigDecimal> for BigDecimal
impl<'a> MulAssign<&'a BigDecimal> for BigDecimal
Sourceยงfn mul_assign(&mut self, rhs: &BigDecimal)
fn mul_assign(&mut self, rhs: &BigDecimal)
*=
operation. Read moreSourceยงimpl<'a> MulAssign<&'a BigInt> for BigDecimal
impl<'a> MulAssign<&'a BigInt> for BigDecimal
Sourceยงfn mul_assign(&mut self, rhs: &BigInt)
fn mul_assign(&mut self, rhs: &BigInt)
*=
operation. Read moreSourceยงimpl MulAssign<BigInt> for BigDecimal
impl MulAssign<BigInt> for BigDecimal
Sourceยงfn mul_assign(&mut self, rhs: BigInt)
fn mul_assign(&mut self, rhs: BigInt)
*=
operation. Read moreSourceยงimpl MulAssign for BigDecimal
impl MulAssign for BigDecimal
Sourceยงfn mul_assign(&mut self, other: BigDecimal)
fn mul_assign(&mut self, other: BigDecimal)
*=
operation. Read moreSourceยงimpl<'a> Neg for &'a BigDecimal
impl<'a> Neg for &'a BigDecimal
Sourceยงtype Output = BigDecimal
type Output = BigDecimal
-
operator.Sourceยงfn neg(self) -> BigDecimal
fn neg(self) -> BigDecimal
-
operation. Read moreSourceยงimpl Neg for BigDecimal
impl Neg for BigDecimal
Sourceยงtype Output = BigDecimal
type Output = BigDecimal
-
operator.Sourceยงfn neg(self) -> BigDecimal
fn neg(self) -> BigDecimal
-
operation. Read moreSourceยงimpl Num for BigDecimal
impl Num for BigDecimal
Sourceยงfn from_str_radix(
s: &str,
radix: u32,
) -> Result<BigDecimal, ParseBigDecimalError>
fn from_str_radix( s: &str, radix: u32, ) -> Result<BigDecimal, ParseBigDecimalError>
Creates and initializes a BigDecimal.
type FromStrRadixErr = ParseBigDecimalError
Sourceยงimpl One for BigDecimal
impl One for BigDecimal
Sourceยงfn one() -> BigDecimal
fn one() -> BigDecimal
Sourceยงimpl Ord for BigDecimal
impl Ord for BigDecimal
Sourceยงfn cmp(&self, other: &BigDecimal) -> Ordering
fn cmp(&self, other: &BigDecimal) -> Ordering
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 ยท Sourceยงfn max(self, other: Self) -> Selfwhere
Self: Sized,
fn max(self, other: Self) -> Selfwhere
Self: Sized,
Sourceยงimpl PartialEq for BigDecimal
impl PartialEq for BigDecimal
Sourceยงimpl PartialOrd for BigDecimal
impl PartialOrd for BigDecimal
Sourceยงimpl PgHasArrayType for BigDecimal
impl PgHasArrayType for BigDecimal
fn array_type_info() -> PgTypeInfo
fn array_compatible(ty: &PgTypeInfo) -> bool
Sourceยงimpl<'a, 'b> Rem<&'b BigDecimal> for &'a BigDecimal
impl<'a, 'b> Rem<&'b BigDecimal> for &'a BigDecimal
Sourceยงtype Output = BigDecimal
type Output = BigDecimal
%
operator.Sourceยงfn rem(self, other: &BigDecimal) -> BigDecimal
fn rem(self, other: &BigDecimal) -> BigDecimal
%
operation. Read moreSourceยงimpl<'a> Rem<&'a BigDecimal> for BigDecimal
impl<'a> Rem<&'a BigDecimal> for BigDecimal
Sourceยงtype Output = BigDecimal
type Output = BigDecimal
%
operator.Sourceยงfn rem(self, other: &BigDecimal) -> BigDecimal
fn rem(self, other: &BigDecimal) -> BigDecimal
%
operation. Read moreSourceยงimpl<'a> Rem<BigDecimal> for &'a BigDecimal
impl<'a> Rem<BigDecimal> for &'a BigDecimal
Sourceยงtype Output = BigDecimal
type Output = BigDecimal
%
operator.Sourceยงfn rem(self, other: BigDecimal) -> BigDecimal
fn rem(self, other: BigDecimal) -> BigDecimal
%
operation. Read moreSourceยงimpl Rem for BigDecimal
impl Rem for BigDecimal
Sourceยงtype Output = BigDecimal
type Output = BigDecimal
%
operator.Sourceยงfn rem(self, other: BigDecimal) -> BigDecimal
fn rem(self, other: BigDecimal) -> BigDecimal
%
operation. Read moreSourceยงimpl Signed for BigDecimal
impl Signed for BigDecimal
Sourceยงfn abs(&self) -> BigDecimal
fn abs(&self) -> BigDecimal
Sourceยงfn abs_sub(&self, other: &BigDecimal) -> BigDecimal
fn abs_sub(&self, other: &BigDecimal) -> BigDecimal
Sourceยงfn signum(&self) -> BigDecimal
fn signum(&self) -> BigDecimal
Sourceยงfn is_positive(&self) -> bool
fn is_positive(&self) -> bool
Sourceยงfn is_negative(&self) -> bool
fn is_negative(&self) -> bool
Sourceยงimpl<'a, 'b> Sub<&'b BigDecimal> for &'a BigDecimal
impl<'a, 'b> Sub<&'b BigDecimal> for &'a BigDecimal
Sourceยงtype Output = BigDecimal
type Output = BigDecimal
-
operator.Sourceยงfn sub(self, rhs: &BigDecimal) -> BigDecimal
fn sub(self, rhs: &BigDecimal) -> BigDecimal
-
operation. Read moreSourceยงimpl<'a> Sub<&'a BigDecimal> for BigDecimal
impl<'a> Sub<&'a BigDecimal> for BigDecimal
Sourceยงtype Output = BigDecimal
type Output = BigDecimal
-
operator.Sourceยงfn sub(self, rhs: &BigDecimal) -> BigDecimal
fn sub(self, rhs: &BigDecimal) -> BigDecimal
-
operation. Read moreSourceยงimpl<'a, 'b> Sub<&'a BigInt> for &'b BigDecimal
impl<'a, 'b> Sub<&'a BigInt> for &'b BigDecimal
Sourceยงtype Output = BigDecimal
type Output = BigDecimal
-
operator.Sourceยงimpl<'a> Sub<&'a BigInt> for BigDecimal
impl<'a> Sub<&'a BigInt> for BigDecimal
Sourceยงtype Output = BigDecimal
type Output = BigDecimal
-
operator.Sourceยงimpl<'a> Sub<BigDecimal> for &'a BigDecimal
impl<'a> Sub<BigDecimal> for &'a BigDecimal
Sourceยงtype Output = BigDecimal
type Output = BigDecimal
-
operator.Sourceยงfn sub(self, rhs: BigDecimal) -> BigDecimal
fn sub(self, rhs: BigDecimal) -> BigDecimal
-
operation. Read moreSourceยงimpl<'a> Sub<BigInt> for &'a BigDecimal
impl<'a> Sub<BigInt> for &'a BigDecimal
Sourceยงtype Output = BigDecimal
type Output = BigDecimal
-
operator.Sourceยงimpl Sub<BigInt> for BigDecimal
impl Sub<BigInt> for BigDecimal
Sourceยงtype Output = BigDecimal
type Output = BigDecimal
-
operator.Sourceยงimpl Sub for BigDecimal
impl Sub for BigDecimal
Sourceยงtype Output = BigDecimal
type Output = BigDecimal
-
operator.Sourceยงfn sub(self, rhs: BigDecimal) -> BigDecimal
fn sub(self, rhs: BigDecimal) -> BigDecimal
-
operation. Read moreSourceยงimpl<'a> SubAssign<&'a BigDecimal> for BigDecimal
impl<'a> SubAssign<&'a BigDecimal> for BigDecimal
Sourceยงfn sub_assign(&mut self, rhs: &BigDecimal)
fn sub_assign(&mut self, rhs: &BigDecimal)
-=
operation. Read moreSourceยงimpl<'a> SubAssign<&'a BigInt> for BigDecimal
impl<'a> SubAssign<&'a BigInt> for BigDecimal
Sourceยงfn sub_assign(&mut self, rhs: &BigInt)
fn sub_assign(&mut self, rhs: &BigInt)
-=
operation. Read moreSourceยงimpl<'a> SubAssign<BigInt> for BigDecimal
impl<'a> SubAssign<BigInt> for BigDecimal
Sourceยงfn sub_assign(&mut self, rhs: BigInt)
fn sub_assign(&mut self, rhs: BigInt)
-=
operation. Read moreSourceยงimpl SubAssign for BigDecimal
impl SubAssign for BigDecimal
Sourceยงfn sub_assign(&mut self, other: BigDecimal)
fn sub_assign(&mut self, other: BigDecimal)
-=
operation. Read moreSourceยงimpl<'a> Sum<&'a BigDecimal> for BigDecimal
impl<'a> Sum<&'a BigDecimal> for BigDecimal
Sourceยงfn sum<I>(iter: I) -> BigDecimalwhere
I: Iterator<Item = &'a BigDecimal>,
fn sum<I>(iter: I) -> BigDecimalwhere
I: Iterator<Item = &'a BigDecimal>,
Self
from the elements by โsumming upโ
the items.Sourceยงimpl Sum for BigDecimal
impl Sum for BigDecimal
Sourceยงfn sum<I>(iter: I) -> BigDecimalwhere
I: Iterator<Item = BigDecimal>,
fn sum<I>(iter: I) -> BigDecimalwhere
I: Iterator<Item = BigDecimal>,
Self
from the elements by โsumming upโ
the items.Sourceยงimpl ToBigInt for BigDecimal
impl ToBigInt for BigDecimal
Sourceยงimpl ToPrimitive for BigDecimal
impl ToPrimitive for BigDecimal
Sourceยงfn to_i64(&self) -> Option<i64>
fn to_i64(&self) -> Option<i64>
self
to an i64
. If the value cannot be
represented by an i64
, then None
is returned.Sourceยงfn to_u64(&self) -> Option<u64>
fn to_u64(&self) -> Option<u64>
self
to a u64
. If the value cannot be
represented by a u64
, then None
is returned.Sourceยงfn to_f64(&self) -> Option<f64>
fn to_f64(&self) -> Option<f64>
self
to an f64
. Overflows may map to positive
or negative inifinity, otherwise None
is returned if the value cannot
be represented by an f64
. Read moreSourceยงfn to_isize(&self) -> Option<isize>
fn to_isize(&self) -> Option<isize>
self
to an isize
. If the value cannot be
represented by an isize
, then None
is returned.Sourceยงfn to_i8(&self) -> Option<i8>
fn to_i8(&self) -> Option<i8>
self
to an i8
. If the value cannot be
represented by an i8
, then None
is returned.Sourceยงfn to_i16(&self) -> Option<i16>
fn to_i16(&self) -> Option<i16>
self
to an i16
. If the value cannot be
represented by an i16
, then None
is returned.Sourceยงfn to_i32(&self) -> Option<i32>
fn to_i32(&self) -> Option<i32>
self
to an i32
. If the value cannot be
represented by an i32
, then None
is returned.Sourceยงfn to_i128(&self) -> Option<i128>
fn to_i128(&self) -> Option<i128>
self
to an i128
. If the value cannot be
represented by an i128
(i64
under the default implementation), then
None
is returned. Read moreSourceยงfn to_usize(&self) -> Option<usize>
fn to_usize(&self) -> Option<usize>
self
to a usize
. If the value cannot be
represented by a usize
, then None
is returned.Sourceยงfn to_u8(&self) -> Option<u8>
fn to_u8(&self) -> Option<u8>
self
to a u8
. If the value cannot be
represented by a u8
, then None
is returned.Sourceยงfn to_u16(&self) -> Option<u16>
fn to_u16(&self) -> Option<u16>
self
to a u16
. If the value cannot be
represented by a u16
, then None
is returned.Sourceยงfn to_u32(&self) -> Option<u32>
fn to_u32(&self) -> Option<u32>
self
to a u32
. If the value cannot be
represented by a u32
, then None
is returned.Sourceยงimpl TryFrom<PgNumeric> for BigDecimal
impl TryFrom<PgNumeric> for BigDecimal
Sourceยงimpl TryFrom<f32> for BigDecimal
impl TryFrom<f32> for BigDecimal
Sourceยงtype Error = ParseBigDecimalError
type Error = ParseBigDecimalError
Sourceยงfn try_from(n: f32) -> Result<BigDecimal, <BigDecimal as TryFrom<f32>>::Error>
fn try_from(n: f32) -> Result<BigDecimal, <BigDecimal as TryFrom<f32>>::Error>
Sourceยงimpl TryFrom<f64> for BigDecimal
impl TryFrom<f64> for BigDecimal
Sourceยงtype Error = ParseBigDecimalError
type Error = ParseBigDecimalError
Sourceยงfn try_from(n: f64) -> Result<BigDecimal, <BigDecimal as TryFrom<f64>>::Error>
fn try_from(n: f64) -> Result<BigDecimal, <BigDecimal as TryFrom<f64>>::Error>
Sourceยงimpl Type<Postgres> for BigDecimal
impl Type<Postgres> for BigDecimal
Sourceยงimpl Zero for BigDecimal
impl Zero for BigDecimal
impl Eq for BigDecimal
Auto Trait Implementationsยง
impl Freeze for BigDecimal
impl RefUnwindSafe for BigDecimal
impl Send for BigDecimal
impl Sync for BigDecimal
impl Unpin for BigDecimal
impl UnwindSafe for BigDecimal
Blanket Implementationsยง
Sourceยงimpl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Sourceยงfn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Sourceยงimpl<T> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
Sourceยงimpl<Q, K> Comparable<K> for Q
impl<Q, K> Comparable<K> for Q
Sourceยงimpl<Q, K> Equivalent<K> for Q
impl<Q, K> Equivalent<K> for Q
Sourceยงimpl<Q, K> Equivalent<K> for Q
impl<Q, K> Equivalent<K> for Q
Sourceยงfn equivalent(&self, key: &K) -> bool
fn equivalent(&self, key: &K) -> bool
key
and return true
if they are equal.Sourceยงimpl<I> FromRadix10 for I
impl<I> FromRadix10 for I
Sourceยงimpl<I> FromRadix10Signed for I
impl<I> FromRadix10Signed for I
Sourceยงimpl<I> FromRadix16 for I
impl<I> FromRadix16 for I
Sourceยงimpl<T> Instrument for T
impl<T> Instrument for T
Sourceยงfn instrument(self, span: Span) -> Instrumented<Self>
fn instrument(self, span: Span) -> Instrumented<Self>
Sourceยงfn in_current_span(self) -> Instrumented<Self>
fn in_current_span(self) -> Instrumented<Self>
Sourceยงimpl<T> IntoEither for T
impl<T> IntoEither for T
Sourceยงfn into_either(self, into_left: bool) -> Either<Self, Self> โ
fn into_either(self, into_left: bool) -> Either<Self, Self> โ
self
into a Left
variant of Either<Self, Self>
if into_left
is true
.
Converts self
into a Right
variant of Either<Self, Self>
otherwise. Read moreSourceยงfn into_either_with<F>(self, into_left: F) -> Either<Self, Self> โ
fn into_either_with<F>(self, into_left: F) -> Either<Self, Self> โ
self
into a Left
variant of Either<Self, Self>
if into_left(&self)
returns true
.
Converts self
into a Right
variant of Either<Self, Self>
otherwise. Read more