pub enum Rounding {
Floor,
Ceil,
Trunc,
Expand,
}Expand description
The rounding direction of an inexact result.
Math.Rounding in Solidity, with the same four cases and the same
discriminant order.
Variants§
Floor
Toward negative infinity. For an unsigned value, the same as
Trunc.
Ceil
Toward positive infinity. For an unsigned value, the same as
Expand.
Trunc
Toward zero.
Expand
Away from zero.
Implementations§
Source§impl Rounding
impl Rounding
Sourcepub const fn unsigned_rounds_up(self) -> bool
pub const fn unsigned_rounds_up(self) -> bool
Whether this direction rounds an inexact unsigned result up.
Math.unsignedRoundsUp. Both signed directions collapse for a value
that cannot be negative: rounding toward positive infinity and rounding
away from zero are the same instruction.
Sourcepub const fn rounds_away_from_zero(self, negative: bool) -> bool
pub const fn rounds_away_from_zero(self, negative: bool) -> bool
Whether this direction rounds an inexact result of the given sign away from zero.
The signed counterpart of unsigned_rounds_up:
Floor grows a negative magnitude, Ceil
a positive one.
Trait Implementations§
impl Copy for Rounding
impl Eq for Rounding
impl StructuralPartialEq for Rounding
Auto Trait Implementations§
impl Freeze for Rounding
impl RefUnwindSafe for Rounding
impl Send for Rounding
impl Sync for Rounding
impl Unpin for Rounding
impl UnsafeUnpin for Rounding
impl UnwindSafe for Rounding
Blanket Implementations§
Source§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
Mutably borrows from an owned value. Read more