Skip to content

Commit

Permalink
implement fuzzy_eq with fuzzy_eq_eps
Browse files Browse the repository at this point in the history
  • Loading branch information
thestinger committed Jan 29, 2013
1 parent fce6446 commit e0728d4
Showing 1 changed file with 4 additions and 4 deletions.
8 changes: 4 additions & 4 deletions src/libstd/cmp.rs
Original file line number Diff line number Diff line change
@@ -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.
//
Expand All @@ -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 {
Expand All @@ -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 {
Expand All @@ -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 {
Expand Down

0 comments on commit e0728d4

Please # to comment.