Hash code for a rational number
<p>I have implemented a class to model rational numbers in java, it has two integers to model numerator and denominator. I am required to override the hashcode method of Object, so the same numbers have the same hash code. </p>

<p>I have defined my equals() method like this:</p>

<pre><code>public boolean equals(Object obj) {
    Racional r = null;
    if (obj instanceof Racional) {
        r = (Racional) obj;
    } else {
        return false;
    }
    return r.getDenominador() * this.numerador == r.getNumerador() * this.denominador;
}
</code></pre>

<p>Regarding this:</p>

<p>Would returning numerator * denominator be a good approach?</p>

<p>Should equivalent rational numbers (like 1/4 and 2/8) return the same hashcode? </p>
