File tree Expand file tree Collapse file tree 2 files changed +18
-0
lines changed Expand file tree Collapse file tree 2 files changed +18
-0
lines changed Original file line number Diff line number Diff line change @@ -43,6 +43,15 @@ impl Decimal {
43
43
44
44
/// Creates a Decimal(value)
45
45
/// This is equivalent to `Decimal::from_atomics(value, 18)` but usable in a const context.
46
+ ///
47
+ /// ## Examples
48
+ ///
49
+ /// ```
50
+ /// # use cosmwasm_std::{Uint128, Decimal};
51
+ /// let atoms = Uint128::new(141_183_460_469_231_731_687_303_715_884_105_727_125);
52
+ /// let value = Decimal::new(atoms);
53
+ /// assert_eq!(value.to_string(), "141183460469231731687.303715884105727125");
54
+ /// ```
46
55
pub const fn new ( value : Uint128 ) -> Self {
47
56
Self ( value)
48
57
}
Original file line number Diff line number Diff line change @@ -48,6 +48,15 @@ impl Decimal256 {
48
48
49
49
/// Creates a Decimal256 from Uint256
50
50
/// This is equivalent to `Decimal256::from_atomics(value, 18)` but usable in a const context.
51
+ ///
52
+ /// ## Examples
53
+ ///
54
+ /// ```
55
+ /// # use cosmwasm_std::{Uint256, Decimal256};
56
+ /// let atoms = Uint256::new(141_183_460_469_231_731_687_303_715_884_105_727_125);
57
+ /// let value = Decimal256::new(atoms);
58
+ /// assert_eq!(value.to_string(), "141183460469231731687.303715884105727125");
59
+ /// ```
51
60
pub const fn new ( value : Uint256 ) -> Self {
52
61
Self ( value)
53
62
}
You can’t perform that action at this time.
0 commit comments