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()