Struct cosmwasm_std::Uint256 [−][src]
pub struct Uint256(_);
Expand description
An implementation of u256 that is using strings for JSON encoding/decoding, such that the full u256 range can be used for clients that convert JSON numbers to floats, like JavaScript and jq.
Examples
Use from
to create instances out of primitive uint types or new
to provide big
endian bytes:
let a = Uint256::from(258u128);
let b = Uint256::new([
0u8, 0u8, 0u8, 0u8, 0u8, 0u8, 0u8, 0u8,
0u8, 0u8, 0u8, 0u8, 0u8, 0u8, 0u8, 0u8,
0u8, 0u8, 0u8, 0u8, 0u8, 0u8, 0u8, 0u8,
0u8, 0u8, 0u8, 0u8, 0u8, 0u8, 1u8, 2u8,
]);
assert_eq!(a, b);
Implementations
Creates a Uint256(value) from a big endian representation. It’s just an alias for
Uint256::from_be_bytes
.
This method is less flexible than from
but can be called in a const context.
Returns a copy of the number as big endian bytes.
Returns a copy of the number as little endian bytes.
Returns self * numerator / denominator
Trait Implementations
Performs the +=
operation. Read more
Performs the +=
operation. Read more
Deserialized from an integer string using base 10
Performs the /=
operation. Read more
Performs the /=
operation. Read more
Performs the /=
operation. Read more
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).
Performs the *=
operation. Read more
Performs the *=
operation. 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
Performs the >>=
operation. Read more
Performs the >>=
operation. Read more
Performs the -=
operation. Read more
Performs the -=
operation. Read more
Auto Trait Implementations
impl RefUnwindSafe for Uint256
impl UnwindSafe for Uint256
Blanket Implementations
Mutably borrows from an owned value. Read more