mirror of
https://github.com/nushell/nushell
synced 2025-01-15 22:54:16 +00:00
Do not allow precision interval to rach < epsilon
This commit is contained in:
parent
2f04c172fe
commit
013b12a864
1 changed files with 3 additions and 3 deletions
|
@ -153,11 +153,11 @@ impl RangeIterator {
|
||||||
}
|
}
|
||||||
|
|
||||||
// Compare two floating point numbers. The decision interval for equality is dynamically scaled
|
// 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> {
|
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);
|
return Some(Ordering::Equal);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue