pub enum FpError {
InfiniteInput,
OutOfDomain,
Indeterminate,
Overflow(Sign),
Underflow(Sign),
}Expand description
Error returned by floating-point operations that cannot produce a usable result.
§Errors vs. special values
Infinite outputs (e.g. 1/0 → +inf, ln(0) → -inf) are not errors — they are
legitimate Exact values produced by operations whose mathematical result is genuinely
infinite. Overflow and underflow are distinct: the mathematical result is finite, but its
magnitude exceeds the representable exponent range. These are reported as
Overflow / Underflow, and converted to
signed infinity / signed zero at the convenience layer via Context::unwrap_fp (or the
Repr-level counterpart Context::unwrap_fp_repr). Because the true result was finite,
the converted value is always Inexact with Rounding::NoOp.
The remaining variants (InfiniteInput,
OutOfDomain, Indeterminate) signal
that an operation could not proceed, and always panic at the convenience layer.
Variants§
InfiniteInput
An operand was infinite. Infinities are terminal values: they can be produced and compared, but not fed back into arithmetic.
OutOfDomain
The mathematical result is not a real number (domain error), e.g. sqrt(-x) for x > 0,
ln(-x), asin(|x| > 1), pow(negative, non-integer), an even root of a negative value.
Indeterminate
An indeterminate form, e.g. 0 / 0. Only a zero divided by zero is
indeterminate — a non-zero value divided by zero yields ±infinity, which is a
legitimate Exact value rather than an error.
Overflow(Sign)
The result magnitude is too large to represent as a finite number.
At the FBig convenience layer this is converted to a signed infinity via
Context::unwrap_fp (or to a signed Repr via Context::unwrap_fp_repr).
The converted result is always Inexact: the true result was a very large
finite number, and infinity is an approximation.
Underflow(Sign)
The result magnitude is too small to represent as a finite non-zero number.
At the FBig convenience layer this is converted to a signed zero via
Context::unwrap_fp (or to a signed Repr via Context::unwrap_fp_repr).
The converted result is always Inexact: the true result was a very small
non-zero number, and zero is an approximation.
Trait Implementations§
impl Copy for FpError
impl Eq for FpError
Source§impl Error for FpError
Available on crate feature std only.
impl Error for FpError
std only.1.30.0 · Source§fn source(&self) -> Option<&(dyn Error + 'static)>
fn source(&self) -> Option<&(dyn Error + 'static)>
1.0.0 · Source§fn description(&self) -> &str
fn description(&self) -> &str
use the Display impl or to_string()
impl StructuralPartialEq for FpError
Auto Trait Implementations§
impl Freeze for FpError
impl RefUnwindSafe for FpError
impl Send for FpError
impl Sync for FpError
impl Unpin for FpError
impl UnsafeUnpin for FpError
impl UnwindSafe for FpError
Blanket Implementations§
Source§impl<T> AggregateExpressionMethods for T
impl<T> AggregateExpressionMethods for T
Source§fn aggregate_distinct(self) -> Self::Outputwhere
Self: DistinctDsl,
fn aggregate_distinct(self) -> Self::Outputwhere
Self: DistinctDsl,
DISTINCT modifier for aggregate functions Read moreSource§fn aggregate_all(self) -> Self::Outputwhere
Self: AllDsl,
fn aggregate_all(self) -> Self::Outputwhere
Self: AllDsl,
ALL modifier for aggregate functions Read moreSource§fn aggregate_filter<P>(self, f: P) -> Self::Output
fn aggregate_filter<P>(self, f: P) -> Self::Output
Source§fn aggregate_order<O>(self, o: O) -> Self::Outputwhere
Self: OrderAggregateDsl<O>,
fn aggregate_order<O>(self, o: O) -> Self::Outputwhere
Self: OrderAggregateDsl<O>,
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
Source§impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
Source§impl<T> Downcast for Twhere
T: Any,
impl<T> Downcast for Twhere
T: Any,
Source§fn into_any(self: Box<T>) -> Box<dyn Any>
fn into_any(self: Box<T>) -> Box<dyn Any>
Box<dyn Trait> (where Trait: Downcast) to Box<dyn Any>, which can then be
downcast into Box<dyn ConcreteType> where ConcreteType implements Trait.Source§fn into_any_rc(self: Rc<T>) -> Rc<dyn Any>
fn into_any_rc(self: Rc<T>) -> Rc<dyn Any>
Rc<Trait> (where Trait: Downcast) to Rc<Any>, which can then be further
downcast into Rc<ConcreteType> where ConcreteType implements Trait.Source§fn as_any(&self) -> &(dyn Any + 'static)
fn as_any(&self) -> &(dyn Any + 'static)
&Trait (where Trait: Downcast) to &Any. This is needed since Rust cannot
generate &Any’s vtable from &Trait’s.Source§fn as_any_mut(&mut self) -> &mut (dyn Any + 'static)
fn as_any_mut(&mut self) -> &mut (dyn Any + 'static)
&mut Trait (where Trait: Downcast) to &Any. This is needed since Rust cannot
generate &mut Any’s vtable from &mut Trait’s.Source§impl<T> DowncastSend for T
impl<T> DowncastSend for T
Source§impl<T> DowncastSync for T
impl<T> DowncastSync for T
Source§impl<T> IntoSql for T
impl<T> IntoSql for T
Source§fn into_sql<T>(self) -> Self::Expressionwhere
Self: Sized + AsExpression<T>,
fn into_sql<T>(self) -> Self::Expressionwhere
Self: Sized + AsExpression<T>,
self to an expression for Diesel’s query builder. Read moreSource§fn as_sql<'a, T>(&'a self) -> <&'a Self as AsExpression<T>>::Expressionwhere
&'a Self: AsExpression<T>,
fn as_sql<'a, T>(&'a self) -> <&'a Self as AsExpression<T>>::Expressionwhere
&'a Self: AsExpression<T>,
&self to an expression for Diesel’s query builder. Read moreSource§impl<T> IntoSql for T
impl<T> IntoSql for T
Source§fn into_sql<T>(self) -> Self::Expression
fn into_sql<T>(self) -> Self::Expression
self to an expression for Diesel’s query builder. Read moreSource§fn as_sql<'a, T>(&'a self) -> <&'a Self as AsExpression<T>>::Expression
fn as_sql<'a, T>(&'a self) -> <&'a Self as AsExpression<T>>::Expression
&self to an expression for Diesel’s query builder. Read more