forked from extern/nushell
Do not allow precision interval to rach < epsilon
This commit is contained in:
parent
2f04c172fe
commit
013b12a864
@ -153,11 +153,11 @@ impl RangeIterator {
|
||||
}
|
||||
|
||||
// Compare two floating point numbers. The decision interval for equality is dynamically scaled
|
||||
// based on the value being compared.
|
||||
// as the value being compared increases in magnitude.
|
||||
fn compare_floats(val: f64, other: f64) -> Option<Ordering> {
|
||||
let prec = val * f64::EPSILON;
|
||||
let prec = f64::EPSILON.max(val.abs() * f64::EPSILON);
|
||||
|
||||
if (other - val).abs() < prec.abs() {
|
||||
if (other - val).abs() < prec {
|
||||
return Some(Ordering::Equal);
|
||||
}
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user