[][src]Struct cosmwasm_std::Decimal

pub struct Decimal(_);

A fixed-point decimal value with 18 fractional digits, i.e. Decimal(1_000_000_000_000_000_000) == 1.0

The greatest possible value that can be represented is 340282366920938463463.374607431768211455 (which is (2^128 - 1) / 10^18)


impl Decimal[src]

pub const MAX: Decimal[src]

pub const fn one() -> Decimal[src]

Create a 1.0 Decimal

pub const fn zero() -> Decimal[src]

Create a 0.0 Decimal

pub fn percent(x: u64) -> Decimal[src]

Convert x% into Decimal

pub fn permille(x: u64) -> Decimal[src]

Convert permille (x/1000) into Decimal

pub fn from_ratio<A: Into<u128>, B: Into<u128>>(
    nominator: A,
    denominator: B
) -> Decimal

Returns the ratio (nominator / denominator) as a Decimal

pub fn is_zero(&self) -> bool[src]

Trait Implementations

impl Add<Decimal> for Decimal[src]

type Output = Self

The resulting type after applying the + operator.

impl Clone for Decimal[src]

impl Copy for Decimal[src]

impl Debug for Decimal[src]

impl Default for Decimal[src]

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

Deserializes as a base64 string

impl Display for Decimal[src]

impl Eq for Decimal[src]

impl FromStr for Decimal[src]

type Err = StdError

The associated error which can be returned from parsing.

fn from_str(input: &str) -> Result<Self, Self::Err>[src]

Converts the decimal string to a Decimal Possible inputs: "1.23", "1", "000012", "1.123000000" Disallowed: "", ".23"

This never performs any kind of rounding. More than 18 fractional digits, even zeros, result in an error.

impl JsonSchema for Decimal[src]

impl Mul<Decimal> for Uint128[src]

Both du and ud with d: Decimal and u: Uint128 returns an Uint128. There is no specific reason for this decision other than the initial use cases we have. If you need a Decimal result for the same calculation, use Decimal(du) or Decimal(ud).

type Output = Self

The resulting type after applying the * operator.

impl Mul<Uint128> for Decimal[src]

type Output = Uint128

The resulting type after applying the * operator.

impl Ord for Decimal[src]

impl PartialEq<Decimal> for Decimal[src]

impl PartialOrd<Decimal> for Decimal[src]

impl Serialize for Decimal[src]

Serializes as a decimal string

impl StructuralEq for Decimal[src]

impl StructuralPartialEq for Decimal[src]

Auto Trait Implementations

impl RefUnwindSafe for Decimal

impl Send for Decimal

impl Sync for Decimal

impl Unpin for Decimal

impl UnwindSafe for Decimal

Blanket Implementations

impl<T> Any for T where
    T: 'static + ?Sized

impl<T> Borrow<T> for T where
    T: ?Sized

impl<T> BorrowMut<T> for T where
    T: ?Sized

impl<T> DeserializeOwned for T where
    T: for<'de> Deserialize<'de>, 

impl<T> From<T> for T[src]

impl<T, U> Into<U> for T where
    U: From<T>, 

impl<T> ToOwned for T where
    T: Clone

type Owned = T

The resulting type after obtaining ownership.

impl<T> ToString for T where
    T: Display + ?Sized

impl<T, U> TryFrom<U> for T where
    U: Into<T>, 

type Error = Infallible

The type returned in the event of a conversion error.

impl<T, U> TryInto<U> for T where
    U: TryFrom<T>, 

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.