Trait mpmfnum::RoundingContext
source · pub trait RoundingContext {
type Format: Real;
// Required method
fn round<T: Real>(&self, val: &T) -> Self::Format;
}
Expand description
Universal trait for rounding contexts.
Most mathematical operators on digital numbers can be decomposed into two steps: first, a mathematically-correct operation over real numbers, interpreting digital numbers as real numbers; second, a rounding operation to limit the number significant digits and decide how the “lost” digits will affect the final output. Thus, rounding enforces a particular “format” for digital numbers, but they should just be considered unbounded real numbers when in isolation. The characteristics of the rounding operation are summarized in a “rounding context”. All mathematical evaluation is done under a particular rounding context.
See Real
for details on the number trait.
Required Associated Types§
Required Methods§
sourcefn round<T: Real>(&self, val: &T) -> Self::Format
fn round<T: Real>(&self, val: &T) -> Self::Format
Rounds any Real
value to a RoundingContext::Format
value,
rounding according to this RoundingContext
.