return getFraction(Double.parseDouble(str)); int numer = Integer.parseInt(str.substring(0, pos)); int denom = Integer.parseInt(str.substring(pos + 1)); return getFraction(whole, numer, denom); if (pos < 0) { return getFraction(Integer.parseInt(str), 1); } else { int numer = Integer.parseInt(str.substring(0, pos)); int denom = Integer.parseInt(str.substring(pos + 1)); return getFraction(numer, denom);
/** * <p>Reduce the fraction to the smallest values for the numerator and * denominator, returning the result.</p> * * <p>For example, if this fraction represents 2/4, then the result * will be 1/2.</p> * * @return a new reduced fraction instance, or this if no simplification possible */ public Fraction reduce() { if (numerator == 0) { return equals(ZERO) ? this : ZERO; } int gcd = greatestCommonDivisor(Math.abs(numerator), denominator); if (gcd == 1) { return this; } return Fraction.getFraction(numerator / gcd, denominator / gcd); }
public boolean failuresRatioExceeds(double threshold) { if (hasFailures()) { Fraction failuresRatio = getFraction(failures.intValue(), failures.intValue() + successes.intValue()); return failuresRatio.compareTo(getFraction(threshold)) > 0; } return false; }
public boolean failuresRatioExceeds(double threshold) { if (hasFailures()) { Fraction failuresRatio = getFraction(failures.intValue(), failures.intValue() + successes.intValue()); return failuresRatio.compareTo(getFraction(threshold)) > 0; } return false; }
return getFraction(Double.parseDouble(str)); int numer = Integer.parseInt(str.substring(0, pos)); int denom = Integer.parseInt(str.substring(pos + 1)); return getFraction(whole, numer, denom); if (pos < 0) { return getFraction(Integer.parseInt(str), 1); } else { int numer = Integer.parseInt(str.substring(0, pos)); int denom = Integer.parseInt(str.substring(pos + 1)); return getFraction(numer, denom);
return getFraction(Double.parseDouble(str)); int numer = Integer.parseInt(str.substring(0, pos)); int denom = Integer.parseInt(str.substring(pos + 1)); return getFraction(whole, numer, denom); if (pos < 0) { return getFraction(Integer.parseInt(str), 1); } else { int numer = Integer.parseInt(str.substring(0, pos)); int denom = Integer.parseInt(str.substring(pos + 1)); return getFraction(numer, denom);
return getFraction(Double.parseDouble(str)); int numer = Integer.parseInt(str.substring(0, pos)); int denom = Integer.parseInt(str.substring(pos + 1)); return getFraction(whole, numer, denom); if (pos < 0) { return getFraction(Integer.parseInt(str), 1); } else { int numer = Integer.parseInt(str.substring(0, pos)); int denom = Integer.parseInt(str.substring(pos + 1)); return getFraction(numer, denom);
return getFraction(Double.parseDouble(str)); int numer = Integer.parseInt(str.substring(0, pos)); int denom = Integer.parseInt(str.substring(pos + 1)); return getFraction(whole, numer, denom); if (pos < 0) { return getFraction(Integer.parseInt(str), 1); } else { int numer = Integer.parseInt(str.substring(0, pos)); int denom = Integer.parseInt(str.substring(pos + 1)); return getFraction(numer, denom);
return getFraction(Double.parseDouble(str)); int numer = Integer.parseInt(str.substring(0, pos)); int denom = Integer.parseInt(str.substring(pos + 1)); return getFraction(whole, numer, denom); if (pos < 0) { return getFraction(Integer.parseInt(str), 1); } else { int numer = Integer.parseInt(str.substring(0, pos)); int denom = Integer.parseInt(str.substring(pos + 1)); return getFraction(numer, denom);
/** * <p>Reduce the fraction to the smallest values for the numerator and * denominator, returning the result.</p> * * <p>For example, if this fraction represents 2/4, then the result * will be 1/2.</p> * * @return a new reduced fraction instance, or this if no simplification possible */ public Fraction reduce() { if (numerator == 0) { return equals(ZERO) ? this : ZERO; } int gcd = greatestCommonDivisor(Math.abs(numerator), denominator); if (gcd == 1) { return this; } return Fraction.getFraction(numerator / gcd, denominator / gcd); }
/** * <p>Reduce the fraction to the smallest values for the numerator and * denominator, returning the result.</p> * * <p>For example, if this fraction represents 2/4, then the result * will be 1/2.</p> * * @return a new reduced fraction instance, or this if no simplification possible */ public Fraction reduce() { if (numerator == 0) { return equals(ZERO) ? this : ZERO; } int gcd = greatestCommonDivisor(Math.abs(numerator), denominator); if (gcd == 1) { return this; } return Fraction.getFraction(numerator / gcd, denominator / gcd); }
/** * <p>Reduce the fraction to the smallest values for the numerator and * denominator, returning the result.</p> * * <p>For example, if this fraction represents 2/4, then the result * will be 1/2.</p> * * @return a new reduced fraction instance, or this if no simplification possible */ public Fraction reduce() { if (numerator == 0) { return equals(ZERO) ? this : ZERO; } int gcd = greatestCommonDivisor(Math.abs(numerator), denominator); if (gcd == 1) { return this; } return Fraction.getFraction(numerator / gcd, denominator / gcd); }
/** * <p>Reduce the fraction to the smallest values for the numerator and * denominator, returning the result.</p> * * <p>For example, if this fraction represents 2/4, then the result * will be 1/2.</p> * * @return a new reduced fraction instance, or this if no simplification possible */ public Fraction reduce() { if (numerator == 0) { return equals(ZERO) ? this : ZERO; } int gcd = greatestCommonDivisor(Math.abs(numerator), denominator); if (gcd == 1) { return this; } return Fraction.getFraction(numerator / gcd, denominator / gcd); }
/** * <p>Reduce the fraction to the smallest values for the numerator and * denominator, returning the result.</p> * * <p>For example, if this fraction represents 2/4, then the result * will be 1/2.</p> * * @return a new reduced fraction instance, or this if no simplification possible */ public Fraction reduce() { if (numerator == 0) { return equals(ZERO) ? this : ZERO; } int gcd = greatestCommonDivisor(Math.abs(numerator), denominator); if (gcd == 1) { return this; } return Fraction.getFraction(numerator / gcd, denominator / gcd); }
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(); } }
public static void adjustMinMaxFrameRate(AdaptationSetType adaptationSetType) { List<RepresentationType> representations = adaptationSetType.getRepresentation(); Fraction min = null, max = null; for (RepresentationType representationType : representations) { String frameRate = representationType.getFrameRate(); if (frameRate != null) { Fraction f = Fraction.getFraction(frameRate); min = min == null || f.compareTo(min) < 0 ? f : min; max = max == null || f.compareTo(max) > 0 ? f : max; } } if (max != null && !min.equals(max)) { // min/max doesn't make sense when both values are the same adaptationSetType.setMinFrameRate(min.toString()); adaptationSetType.setMaxFrameRate(max.toString()); } }