/** * <p>Gets a hashCode for the fraction.</p> * * @return a hash code value for this object */ public int hashCode() { if (hashCode == 0) { // hashcode update should be atomic. hashCode = 37 * (37 * 17 + getNumerator()) + getDenominator(); } return hashCode; }
/** * <p>Compares this fraction to another object to test if they are equal.</p>. * * <p>To be equal, both values must be equal. Thus 2/4 is not equal to 1/2.</p> * * @param obj the reference object with which to compare * @return <code>true</code> if this object is equal */ public boolean equals(Object obj) { if (obj == this) { return true; } if (obj instanceof Fraction == false) { return false; } Fraction other = (Fraction) obj; return (getNumerator() == other.getNumerator() && getDenominator() == other.getDenominator()); }
/** * <p>Gets the fraction as a <code>String</code>.</p> * * <p>The format used is '<i>numerator</i>/<i>denominator</i>' always. * * @return a <code>String</code> form of the fraction */ public String toString() { if (toString == null) { toString = new StrBuilder(32) .append(getNumerator()) .append('/') .append(getDenominator()).toString(); } return toString; }
.append(getNumerator()).append('/') .append(getDenominator()).toString();
/** * <p>Gets a hashCode for the fraction.</p> * * @return a hash code value for this object */ public int hashCode() { if (hashCode == 0) { // hashcode update should be atomic. hashCode = 37 * (37 * 17 + getNumerator()) + getDenominator(); } return hashCode; }
/** * <p>Gets a hashCode for the fraction.</p> * * @return a hash code value for this object */ public int hashCode() { if (hashCode == 0) { // hashcode update should be atomic. hashCode = 37 * (37 * 17 + getNumerator()) + getDenominator(); } return hashCode; }
/** * <p>Gets a hashCode for the fraction.</p> * * @return a hash code value for this object */ public int hashCode() { if (hashCode == 0) { // hashcode update should be atomic. hashCode = 37 * (37 * 17 + getNumerator()) + getDenominator(); } return hashCode; }
/** * <p>Gets a hashCode for the fraction.</p> * * @return a hash code value for this object */ public int hashCode() { if (hashCode == 0) { // hashcode update should be atomic. hashCode = 37 * (37 * 17 + getNumerator()) + getDenominator(); } return hashCode; }
/** * <p>Gets a hashCode for the fraction.</p> * * @return a hash code value for this object */ public int hashCode() { if (hashCode == 0) { // hashcode update should be atomic. hashCode = 37 * (37 * 17 + getNumerator()) + getDenominator(); } return hashCode; }
/** * <p>Gets the fraction as a <code>String</code>.</p> * * <p>The format used is '<i>numerator</i>/<i>denominator</i>' always. * * @return a <code>String</code> form of the fraction */ public String toString() { if (toString == null) { toString = new StringBuffer(32) .append(getNumerator()) .append('/') .append(getDenominator()).toString(); } return toString; }
/** * <p>Gets the fraction as a <code>String</code>.</p> * * <p>The format used is '<i>numerator</i>/<i>denominator</i>' always. * * @return a <code>String</code> form of the fraction */ public String toString() { if (toString == null) { toString = new StringBuffer(32) .append(getNumerator()) .append('/') .append(getDenominator()).toString(); } return toString; }
/** * <p>Compares this fraction to another object to test if they are equal.</p>. * * <p>To be equal, both values must be equal. Thus 2/4 is not equal to 1/2.</p> * * @param obj the reference object with which to compare * @return <code>true</code> if this object is equal */ public boolean equals(Object obj) { if (obj == this) { return true; } if (obj instanceof Fraction == false) { return false; } Fraction other = (Fraction) obj; return (getNumerator() == other.getNumerator() && getDenominator() == other.getDenominator()); }
/** * <p>Compares this fraction to another object to test if they are equal.</p>. * * <p>To be equal, both values must be equal. Thus 2/4 is not equal to 1/2.</p> * * @param obj the reference object with which to compare * @return <code>true</code> if this object is equal */ public boolean equals(Object obj) { if (obj == this) { return true; } if (obj instanceof Fraction == false) { return false; } Fraction other = (Fraction) obj; return (getNumerator() == other.getNumerator() && getDenominator() == other.getDenominator()); }
/** * <p>Compares this fraction to another object to test if they are equal.</p>. * * <p>To be equal, both values must be equal. Thus 2/4 is not equal to 1/2.</p> * * @param obj the reference object with which to compare * @return <code>true</code> if this object is equal */ public boolean equals(Object obj) { if (obj == this) { return true; } if (obj instanceof Fraction == false) { return false; } Fraction other = (Fraction) obj; return (getNumerator() == other.getNumerator() && getDenominator() == other.getDenominator()); }
/** * <p>Compares this fraction to another object to test if they are equal.</p>. * * <p>To be equal, both values must be equal. Thus 2/4 is not equal to 1/2.</p> * * @param obj the reference object with which to compare * @return <code>true</code> if this object is equal */ public boolean equals(Object obj) { if (obj == this) { return true; } if (obj instanceof Fraction == false) { return false; } Fraction other = (Fraction) obj; return (getNumerator() == other.getNumerator() && getDenominator() == other.getDenominator()); }
/** * <p>Compares this fraction to another object to test if they are equal.</p>. * * <p>To be equal, both values must be equal. Thus 2/4 is not equal to 1/2.</p> * * @param obj the reference object with which to compare * @return <code>true</code> if this object is equal */ public boolean equals(Object obj) { if (obj == this) { return true; } if (obj instanceof Fraction == false) { return false; } Fraction other = (Fraction) obj; return (getNumerator() == other.getNumerator() && getDenominator() == other.getDenominator()); }
public static String convertFramerate(double vrate) { Fraction f1 = Fraction.getFraction((int) (vrate * 1001), 1001); Fraction f2 = Fraction.getFraction((int) (vrate * 1000), 1000); double d1 = Math.abs(f1.doubleValue() - vrate); double d2 = Math.abs(f2.doubleValue() - vrate); if (d1 < d2) { return f1.getNumerator() + "/" + f1.getDenominator(); } else { return f2.getNumerator() + "/" + f2.getDenominator(); } }
/** * <p>Gets the fraction as a <code>String</code>.</p> * * <p>The format used is '<i>numerator</i>/<i>denominator</i>' always. * * @return a <code>String</code> form of the fraction */ public String toString() { if (toString == null) { toString = new StrBuilder(32) .append(getNumerator()) .append('/') .append(getDenominator()).toString(); } return toString; }
/** * <p>Gets the fraction as a <code>String</code>.</p> * * <p>The format used is '<i>numerator</i>/<i>denominator</i>' always. * * @return a <code>String</code> form of the fraction */ public String toString() { if (toString == null) { toString = new StrBuilder(32) .append(getNumerator()) .append('/') .append(getDenominator()).toString(); } return toString; }
/** * <p>Gets the fraction as a <code>String</code>.</p> * * <p>The format used is '<i>numerator</i>/<i>denominator</i>' always. * * @return a <code>String</code> form of the fraction */ public String toString() { if (toString == null) { toString = new StrBuilder(32) .append(getNumerator()) .append('/') .append(getDenominator()).toString(); } return toString; }