Enum scrypto::prelude::rounding_mode::RoundingMode
source · pub enum RoundingMode {
ToPositiveInfinity,
ToNegativeInfinity,
ToZero,
AwayFromZero,
ToNearestMidpointTowardZero,
ToNearestMidpointAwayFromZero,
ToNearestMidpointToEven,
}
Expand description
Defines the rounding strategy.
Following the same naming convention as https://docs.rs/rust_decimal/latest/rust_decimal/enum.RoundingStrategy.html.
Variants§
ToPositiveInfinity
The number is always rounded toward positive infinity, e.g. 3.1 -> 4
, -3.1 -> -3
.
ToNegativeInfinity
The number is always rounded toward negative infinity, e.g. 3.1 -> 3
, -3.1 -> -4
.
ToZero
The number is always rounded toward zero, e.g. 3.1 -> 3
, -3.1 -> -3
.
AwayFromZero
The number is always rounded away from zero, e.g. 3.1 -> 4
, -3.1 -> -4
.
ToNearestMidpointTowardZero
The number is rounded to the nearest, and when it is halfway between two others, it’s rounded toward zero, e.g. 3.5 -> 3
, -3.5 -> -3
.
ToNearestMidpointAwayFromZero
The number is rounded to the nearest, and when it is halfway between two others, it’s rounded away from zero, e.g. 3.5 -> 4
, -3.5 -> -4
.
ToNearestMidpointToEven
The number is rounded to the nearest, and when it is halfway between two others, it’s rounded toward the nearest even number. Also known as “Bankers Rounding”.
Trait Implementations§
source§impl<X> Categorize<X> for RoundingModewhere
X: CustomValueKind,
impl<X> Categorize<X> for RoundingModewhere X: CustomValueKind,
fn value_kind() -> ValueKind<X>
source§impl Clone for RoundingMode
impl Clone for RoundingMode
source§fn clone(&self) -> RoundingMode
fn clone(&self) -> RoundingMode
1.0.0 · source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
source
. Read moresource§impl Debug for RoundingMode
impl Debug for RoundingMode
source§impl<D, X> Decode<X, D> for RoundingModewhere
D: Decoder<X>,
X: CustomValueKind,
impl<D, X> Decode<X, D> for RoundingModewhere D: Decoder<X>, X: CustomValueKind,
source§fn decode_body_with_value_kind(
decoder: &mut D,
value_kind: ValueKind<X>
) -> Result<RoundingMode, DecodeError>
fn decode_body_with_value_kind( decoder: &mut D, value_kind: ValueKind<X> ) -> Result<RoundingMode, DecodeError>
source§impl<C> Describe<C> for RoundingModewhere
C: CustomTypeKind<RustTypeId>,
impl<C> Describe<C> for RoundingModewhere C: CustomTypeKind<RustTypeId>,
source§const TYPE_ID: RustTypeId = ::sbor::RustTypeId::novel_with_code("RoundingMode", &[],
&[115u8, 186u8, 239u8, 125u8, 231u8, 218u8, 140u8, 185u8, 175u8, 159u8,
72u8, 163u8, 3u8, 150u8, 40u8, 5u8, 40u8, 74u8, 55u8, 164u8])
const TYPE_ID: RustTypeId = ::sbor::RustTypeId::novel_with_code("RoundingMode", &[], &[115u8, 186u8, 239u8, 125u8, 231u8, 218u8, 140u8, 185u8, 175u8, 159u8, 72u8, 163u8, 3u8, 150u8, 40u8, 5u8, 40u8, 74u8, 55u8, 164u8])
TYPE_ID
should give a unique identifier for its SBOR schema type.
An SBOR schema type capture details about the SBOR payload, how it should be interpreted, validated and displayed. Read moresource§fn type_data() -> TypeData<C, RustTypeId>
fn type_data() -> TypeData<C, RustTypeId>
source§fn add_all_dependencies(aggregator: &mut TypeAggregator<C>)
fn add_all_dependencies(aggregator: &mut TypeAggregator<C>)
get_local_type_data
, we need to ensure that the type and all of its own references
get added to the aggregator. Read moresource§impl<E, X> Encode<X, E> for RoundingModewhere
E: Encoder<X>,
X: CustomValueKind,
impl<E, X> Encode<X, E> for RoundingModewhere E: Encoder<X>, X: CustomValueKind,
source§fn encode_value_kind(&self, encoder: &mut E) -> Result<(), EncodeError>
fn encode_value_kind(&self, encoder: &mut E) -> Result<(), EncodeError>
source§fn encode_body(&self, encoder: &mut E) -> Result<(), EncodeError>
fn encode_body(&self, encoder: &mut E) -> Result<(), EncodeError>
source§impl PartialEq<RoundingMode> for RoundingMode
impl PartialEq<RoundingMode> for RoundingMode
source§fn eq(&self, other: &RoundingMode) -> bool
fn eq(&self, other: &RoundingMode) -> bool
self
and other
values to be equal, and is used
by ==
.source§impl<X> SborEnum<X> for RoundingModewhere
X: CustomValueKind,
impl<X> SborEnum<X> for RoundingModewhere X: CustomValueKind,
fn get_discriminator(&self) -> u8
fn get_length(&self) -> usize
impl Copy for RoundingMode
impl Eq for RoundingMode
impl StructuralEq for RoundingMode
impl StructuralPartialEq for RoundingMode
Auto Trait Implementations§
impl RefUnwindSafe for RoundingMode
impl Send for RoundingMode
impl Sync for RoundingMode
impl Unpin for RoundingMode
impl UnwindSafe for RoundingMode
Blanket Implementations§
§impl<U> As for U
impl<U> As for U
§fn as_<T>(self) -> Twhere
T: CastFrom<U>,
fn as_<T>(self) -> Twhere T: CastFrom<U>,
self
to type T
. The semantics of numeric casting with the as
operator are followed, so <T as As>::as_::<U>
can be used in the same way as T as U
for numeric conversions. Read moresource§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere T: ?Sized,
source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
source§impl<Q, K> Equivalent<K> for Qwhere
Q: Eq + ?Sized,
K: Borrow<Q> + ?Sized,
impl<Q, K> Equivalent<K> for Qwhere Q: Eq + ?Sized, K: Borrow<Q> + ?Sized,
source§fn equivalent(&self, key: &K) -> bool
fn equivalent(&self, key: &K) -> bool
key
and return true
if they are equal.