diff options
| author | Daniel Micay <danielmicay@gmail.com> | 2013-01-29 15:35:26 -0500 |
|---|---|---|
| committer | Daniel Micay <danielmicay@gmail.com> | 2013-01-29 15:35:26 -0500 |
| commit | e0728d41f2fe9c87e086dc5bcc0260dcffcb7517 (patch) | |
| tree | afaa7f1d410c594555591349c1bc8127cde9428d /src/libstd/cmp.rs | |
| parent | fce6446e7e2683b5cfcc2a36211cec5ab2c355fa (diff) | |
| download | rust-e0728d41f2fe9c87e086dc5bcc0260dcffcb7517.tar.gz rust-e0728d41f2fe9c87e086dc5bcc0260dcffcb7517.zip | |
implement fuzzy_eq with fuzzy_eq_eps
Diffstat (limited to 'src/libstd/cmp.rs')
| -rw-r--r-- | src/libstd/cmp.rs | 8 |
1 files changed, 4 insertions, 4 deletions
diff --git a/src/libstd/cmp.rs b/src/libstd/cmp.rs index d6fc23c6fdd..ef893b067be 100644 --- a/src/libstd/cmp.rs +++ b/src/libstd/cmp.rs @@ -1,4 +1,4 @@ -// Copyright 2013 The Rust Project Developers. See the COPYRIGHT +// Copyright 2012-2013 The Rust Project Developers. See the COPYRIGHT // file at the top-level directory of this distribution and at // http://rust-lang.org/COPYRIGHT. // @@ -24,7 +24,7 @@ pub trait FuzzyEq { impl float: FuzzyEq { pure fn fuzzy_eq(&self, other: &float) -> bool { - float::abs(*self - *other) < fuzzy_epsilon + self.fuzzy_eq_eps(other, fuzzy_epsilon) } pure fn fuzzy_eq_eps(&self, other: &float, epsilon: &float) -> bool { @@ -34,7 +34,7 @@ impl float: FuzzyEq { impl f32: FuzzyEq { pure fn fuzzy_eq(&self, other: &f32) -> bool { - f32::abs(*self - *other) < (fuzzy_epsilon as f32) + self.fuzzy_eq_eps(other, fuzzy_epsilon as f32) } pure fn fuzzy_eq_eps(&self, other: &f32, epsilon: &f32) -> bool { @@ -44,7 +44,7 @@ impl f32: FuzzyEq { impl f64: FuzzyEq { pure fn fuzzy_eq(&self, other: &f64) -> bool { - f64::abs(*self - *other) < (fuzzy_epsilon as f64) + self.fuzzy_eq_eps(other, fuzzy_epsilon as f64) } pure fn fuzzy_eq_eps(&self, other: &f64, epsilon: &f64) -> bool { |
