pub fn test_underflow(result: &Float, o: Ordering) -> boolExpand description
Given the (Float, Ordering) result of an operation, determines whether an underflow occurred.
We’re defining an underflow to occur whenever the actual result is outside the representable finite range, and is rounded to zero, to the minimum positive value, or to the maximum negative value. An underflow can present itself in four ways:
- The result is $0.0$ or $-0.0$ and the
OrderingisLess - The result is $0.0$ or $-0.0$ and the
OrderingisGreater - The result is the smallest positive value and the
OrderingisGreater - The result is the largest (least negative) negative value and the
OrderingisLess
§Worst-case complexity
$T(n) = O(n)$
$M(n) = O(1)$
where $T$ is time, $M$ is additional memory, and $n$ is self.significant_bits().
§Examples
use malachite_base::num::basic::traits::{One, Zero};
use malachite_float::{test_underflow, Float};
use std::cmp::Ordering::*;
assert!(test_underflow(&Float::ZERO, Less));
assert!(test_underflow(&Float::ZERO, Greater));
assert!(test_underflow(&Float::min_positive_value_prec(10), Greater));
assert!(test_underflow(&-Float::min_positive_value_prec(10), Less));
assert!(!test_underflow(&Float::ZERO, Equal));
assert!(!test_underflow(&Float::ONE, Less));