trait TolerantNumerics extends AnyRef
Provides Equality
and Equivalence
instances for Numeric
types that
compare for equality with a given tolerance.
Here's an example:
scala> import org.scalactic._ import org.scalactic._ scala> import TripleEquals._ import TripleEquals._ scala> 2.001 === 2.0 res0: Boolean = false scala> implicit val doubleEquality = TolerantNumerics.tolerantDoubleEquality(0.01) doubleEquality: org.scalactic.Equality[Double] = org.scalactic.TolerantNumerics$$anon$1@16c2bd13 scala> 2.001 === 2.0 res1: Boolean = true
- Source
- TolerantNumerics.scala
- Alphabetic
- By Inheritance
- TolerantNumerics
- AnyRef
- Any
- Hide All
- Show All
- Public
- Protected
Value Members
- def tolerantByteEquality(tolerance: Byte): Equality[Byte]
Provides an
Equality
instance forByte
s that compares for equality with the passed tolerance.Provides an
Equality
instance forByte
s that compares for equality with the passed tolerance.- tolerance
the tolerance with which the returned
Equality
will compareByte
s.- returns
an
Equality
that comparesByte
s using the passed tolerance.
- def tolerantDoubleEquality(tolerance: Double): Equality[Double]
Provides an
Equality
instance forDouble
s that compares for equality with the passed tolerance.Provides an
Equality
instance forDouble
s that compares for equality with the passed tolerance.- tolerance
the tolerance with which the returned
Equality
will compareDouble
s.- returns
an
Equality
that comparesDouble
s using the passed tolerance.
- def tolerantEquivalence[N](tolerance: N)(implicit arg0: Numeric[N]): Equivalence[N]
Provides an
Equivalence[N]
instance for any type for which aNumeric[N]
is available that comparesN
s for equality with the passed tolerance.Provides an
Equivalence[N]
instance for any type for which aNumeric[N]
is available that comparesN
s for equality with the passed tolerance.- tolerance
the tolerance with which the returned
Equality
will compareNumeric
s.- returns
an
Equivalence
that comparesNumeric
s using the passed tolerance.
- def tolerantFloatEquality(tolerance: Float): Equality[Float]
Provides an
Equality
instance forFloat
s that compares for equality with the passed tolerance.Provides an
Equality
instance forFloat
s that compares for equality with the passed tolerance.- tolerance
the tolerance with which the returned
Equality
will compareFloat
s.- returns
an
Equality
that comparesFloat
s using the passed tolerance.
- def tolerantIntEquality(tolerance: Int): Equality[Int]
Provides an
Equality
instance forInt
s that compares for equality with the passed tolerance.Provides an
Equality
instance forInt
s that compares for equality with the passed tolerance.- tolerance
the tolerance with which the returned
Equality
will compareInt
s.- returns
an
Equality
that comparesInt
s using the passed tolerance.
- def tolerantLongEquality(tolerance: Long): Equality[Long]
Provides an
Equality
instance forLong
s that compares for equality with the passed tolerance.Provides an
Equality
instance forLong
s that compares for equality with the passed tolerance.- tolerance
the tolerance with which the returned
Equality
will compareLong
s.- returns
an
Equality
that comparesLong
s using the passed tolerance.
- def tolerantShortEquality(tolerance: Short): Equality[Short]
Provides an
Equality
instance forShort
s that compares for equality with the passed tolerance.Provides an
Equality
instance forShort
s that compares for equality with the passed tolerance.- tolerance
the tolerance with which the returned
Equality
will compareShort
s.- returns
an
Equality
that comparesShort
s using the passed tolerance.