  class FuzzyDouble(self : Double) extends Ordered[Double]
  {
	private[this] val ratio = 0.6

    def compare(other : Double) =
    {
      if(self < other)
      {
        if(self >= ratio * other) 0
        else -1
      }
      else if(self > other)
      {
        if(other >= ratio * self) 0
        else +1
      }
      else 0
    }

    def equals(other : Double) = (compare(other) == 0)
	override def equals(other : Any) = if(other.isInstanceOf[Double]) 
	{
		equals( other.asInstanceOf[Double])
	} 
	else false

	override def hashCode = self.hashCode
  }

  implicit def fuzzy(d : Double) = new FuzzyDouble(d)  

  def areEqual[T <% Ordered[T]](a : T, b : T)
  {
    // wrong: no conversion  because type T is erased to 'Any', which has a matching '== '-method
    println("a == b : " + (a == b)) 
   // right: calls compare on the converted type because 'Any' has no such method
    println("(a compare b) == 0 : " + ((a compare b) == 0)) 
  }

  areEqual(1.0,1.5)(fuzzy)
