[][src]Struct cosmwasm_bignumber::Decimal256

pub struct Decimal256(pub U256);

A fixed-point decimal value with 18 fractional digits, i.e. Decimal256(1_000_000_000_000_000_000) == 1.0 The greatest possible value that can be represented is 115792089237316195423570985008687907853269984665640564039457.584007913129639935 (which is (2^128 - 1) / 10^18)

Implementations

impl Decimal256[src]

pub const MAX: Decimal256[src]

pub const DECIMAL_FRACTIONAL: U256[src]

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

Create a 1.0 Decimal256

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

Create a 0.0 Decimal256

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

Convert x% into Decimal256

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

Convert permille (x/1000) into Decimal256

pub fn from_ratio<A: Into<U256>, B: Into<U256>>(
    nominator: A,
    denominator: B
) -> Decimal256
[src]

Returns the ratio (nominator / denominator) as a Decimal256

pub fn from_uint256<A: Into<Uint256>>(val: A) -> Decimal256[src]

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

Trait Implementations

impl Add<Decimal256> for Decimal256[src]

type Output = Self

The resulting type after applying the + operator.

impl AddAssign<Decimal256> for Decimal256[src]

impl Clone for Decimal256[src]

impl Copy for Decimal256[src]

impl Debug for Decimal256[src]

impl Default for Decimal256[src]

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

Deserializes as a base64 string

impl Display for Decimal256[src]

impl Div<Decimal256> for Decimal256[src]

type Output = Self

The resulting type after applying the / operator.

impl Div<Decimal256> for Uint256[src]

type Output = Self

The resulting type after applying the / operator.

impl Eq for Decimal256[src]

impl From<Decimal> for Decimal256[src]

impl FromStr for Decimal256[src]

type Err = StdError

The associated error which can be returned from parsing.

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

Converts the decimal string to a Decimal256 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 Into<Decimal> for Decimal256[src]

impl JsonSchema for Decimal256[src]

impl Mul<Decimal256> for Decimal256[src]

type Output = Self

The resulting type after applying the * operator.

impl Mul<Decimal256> for Uint256[src]

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

type Output = Self

The resulting type after applying the * operator.

impl Mul<Uint256> for Decimal256[src]

type Output = Uint256

The resulting type after applying the * operator.

impl Ord for Decimal256[src]

impl PartialEq<Decimal256> for Decimal256[src]

impl PartialOrd<Decimal256> for Decimal256[src]

impl Serialize for Decimal256[src]

Serializes as a decimal string

impl StructuralEq for Decimal256[src]

impl StructuralPartialEq for Decimal256[src]

impl Sub<Decimal256> for Decimal256[src]

type Output = Self

The resulting type after applying the - operator.

Auto Trait Implementations

Blanket Implementations

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

impl<T> Borrow<T> for T where
    T: ?Sized
[src]

impl<T> BorrowMut<T> for T where
    T: ?Sized
[src]

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

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

impl<T, U> Into<U> for T where
    U: From<T>, 
[src]

impl<T> ToOwned for T where
    T: Clone
[src]

type Owned = T

The resulting type after obtaining ownership.

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

impl<T, U> TryFrom<U> for T where
    U: Into<T>, 
[src]

type Error = Infallible

The type returned in the event of a conversion error.

impl<T, U> TryInto<U> for T where
    U: TryFrom<T>, 
[src]

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

The type returned in the event of a conversion error.