# [−][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)

## Implementations

### `impl 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`[src]

Returns the ratio (nominator / denominator) as a Decimal

## Trait Implementations

### `impl Add<Decimal> for Decimal`[src]

#### `type Output = Self`

The resulting type after applying the `+` operator.

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

Deserializes as a base64 string

### `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 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 Serialize for Decimal`[src]

Serializes as a decimal string

## Blanket Implementations

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

#### `type Owned = T`

The resulting type after obtaining ownership.

### `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.