Struct rbatis::types::Decimal [−][src]
pub struct Decimal {
pub inner: BigDecimal,
}
Expand description
Rbatis Decimal
Fields
inner: BigDecimal
Implementations
Methods from Deref<Target = BigDecimal>
pub 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)
Return a new BigDecimal object with precision set to new value
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);
pub 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));
pub fn abs(&self) -> BigDecimal
pub fn abs(&self) -> BigDecimal
Compute the absolute value of number
pub fn double(&self) -> BigDecimal
pub 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.
pub fn square(&self) -> BigDecimal
pub fn square(&self) -> BigDecimal
pub fn cube(&self) -> BigDecimal
Take the square root of the number
If the value is < 0, None is returned
pub fn cbrt(&self) -> BigDecimal
pub fn cbrt(&self) -> BigDecimal
Take the cube root of the number
pub fn inverse(&self) -> BigDecimal
pub fn inverse(&self) -> BigDecimal
Compute the reciprical of the number: x-1
Return number rounded to round_digits precision after the decimal point
pub 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)
pub fn exp(&self) -> BigDecimal
pub fn exp(&self) -> BigDecimal
Evaluate the natural-exponential function ex
pub fn normalized(&self) -> BigDecimal
Trait Implementations
Decimal allow deserialize by an String or Binary
pub fn deserialize<D>(
deserializer: D
) -> Result<Decimal, <D as Deserializer<'de>>::Error> where
D: Deserializer<'de>,
pub fn deserialize<D>(
deserializer: D
) -> Result<Decimal, <D as Deserializer<'de>>::Error> where
D: Deserializer<'de>,
Deserialize this value from the given Serde deserializer. Read more
This method returns an ordering between self
and other
values if one exists. Read more
This method tests less than (for self
and other
) and is used by the <
operator. Read more
This method tests less than or equal to (for self
and other
) and is used by the <=
operator. Read more
This method tests greater than (for self
and other
) and is used by the >
operator. Read more
pub fn serialize<S>(
&self,
serializer: S
) -> Result<<S as Serializer>::Ok, <S as Serializer>::Error> where
S: Serializer,
pub fn serialize<S>(
&self,
serializer: S
) -> Result<<S as Serializer>::Ok, <S as Serializer>::Error> where
S: Serializer,
Serialize this value into the given Serde serializer. Read more
Auto Trait Implementations
impl RefUnwindSafe for Decimal
impl UnwindSafe for Decimal
Blanket Implementations
Mutably borrows from an owned value. Read more
Compare self to key
and return true
if they are equal.