pub enum RoundingMode {
Down,
Up,
TowardZero,
AwayFromZero,
HalfUp,
HalfDown,
HalfEven,
}Expand description
Rounding mode selector (7 modes per IEEE 754-2008).
Variants§
Down
Round toward negative infinity (floor).
-1.5 → -2, 1.5 → 1
Up
Round toward positive infinity (ceiling).
-1.5 → -1, 1.5 → 2
TowardZero
Round toward zero (truncate).
-1.9 → -1, 1.9 → 1
AwayFromZero
Round away from zero.
-1.1 → -2, 1.1 → 2
HalfUp
Round half toward positive infinity (“school” rounding).
0.5 → 1, -0.5 → 0
HalfDown
Round half toward negative infinity.
0.5 → 0, -0.5 → -1
HalfEven
Round half to nearest even digit (banker’s rounding) — default.
0.5 → 0, 1.5 → 2, 2.5 → 2, 3.5 → 4
Chosen as default because it is statistically unbiased across large numbers of operations — critical for interest accrual and index updates.
Trait Implementations§
Source§impl Clone for RoundingMode
impl Clone for RoundingMode
Source§fn clone(&self) -> RoundingMode
fn clone(&self) -> RoundingMode
Returns a duplicate of the value. Read more
1.0.0 · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
Performs copy-assignment from
source. Read moreSource§impl Debug for RoundingMode
impl Debug for RoundingMode
Source§impl Default for RoundingMode
impl Default for RoundingMode
Source§fn default() -> RoundingMode
fn default() -> RoundingMode
Returns the “default value” for a type. Read more
Source§impl Hash for RoundingMode
impl Hash for RoundingMode
Source§impl PartialEq for RoundingMode
impl PartialEq for RoundingMode
impl Copy for RoundingMode
impl Eq for RoundingMode
impl StructuralPartialEq for RoundingMode
Auto Trait Implementations§
impl Freeze for RoundingMode
impl RefUnwindSafe for RoundingMode
impl Send for RoundingMode
impl Sync for RoundingMode
impl Unpin for RoundingMode
impl UnsafeUnpin for RoundingMode
impl UnwindSafe for RoundingMode
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