/**@class android.util.Rational implements java.lang.Comparable @extends java.lang.Number <p>An immutable data type representation a rational number.</p> <p>Contains a pair of {@code int}s representing the numerator and denominator of a Rational number. </p> */ var Rational = { /** Constant for the <em>Not-a-Number (NaN)</em> value of the {@code Rational} type. <p>A {@code NaN} value is considered to be equal to itself (that is {@code NaN.equals(NaN)} will return {@code true}; it is always greater than any non-{@code NaN} value (that is {@code NaN.compareTo(notNaN)} will return a number greater than {@code 0}).</p> <p>Equivalent to constructing a new rational with both the numerator and denominator equal to {@code 0}.</p> */ NaN : "null", /** Constant for the positive infinity value of the {@code Rational} type. <p>Equivalent to constructing a new rational with a positive numerator and a denominator equal to {@code 0}.</p> */ POSITIVE_INFINITY : "null", /** Constant for the negative infinity value of the {@code Rational} type. <p>Equivalent to constructing a new rational with a negative numerator and a denominator equal to {@code 0}.</p> */ NEGATIVE_INFINITY : "null", /** Constant for the zero value of the {@code Rational} type. <p>Equivalent to constructing a new rational with a numerator equal to {@code 0} and any non-zero denominator.</p> */ ZERO : "null", /**Gets the numerator of the rational. <p>The numerator will always return {@code 1} if this rational represents infinity (that is, the denominator is {@code 0}).</p> */ getNumerator : function( ) {}, /**Gets the denominator of the rational <p>The denominator may return {@code 0}, in which case the rational may represent positive infinity (if the numerator was positive), negative infinity (if the numerator was negative), or {@code NaN} (if the numerator was {@code 0}).</p> <p>The denominator will always return {@code 1} if the numerator is {@code 0}. */ getDenominator : function( ) {}, /**Indicates whether this rational is a <em>Not-a-Number (NaN)</em> value. <p>A {@code NaN} value occurs when both the numerator and the denominator are {@code 0}.</p> @return {Boolean} {@code true} if this rational is a <em>Not-a-Number (NaN)</em> value; {@code false} if this is a (potentially infinite) number value */ isNaN : function( ) {}, /**Indicates whether this rational represents an infinite value. <p>An infinite value occurs when the denominator is {@code 0} (but the numerator is not).</p> @return {Boolean} {@code true} if this rational is a (positive or negative) infinite value; {@code false} if this is a finite number value (or {@code NaN}) */ isInfinite : function( ) {}, /**Indicates whether this rational represents a finite value. <p>A finite value occurs when the denominator is not {@code 0}; in other words the rational is neither infinity or {@code NaN}.</p> @return {Boolean} {@code true} if this rational is a (positive or negative) infinite value; {@code false} if this is a finite number value (or {@code NaN}) */ isFinite : function( ) {}, /**Indicates whether this rational represents a zero value. <p>A zero value is a {@link #isFinite finite} rational with a numerator of {@code 0}.</p> @return {Boolean} {@code true} if this rational is finite zero value; {@code false} otherwise */ isZero : function( ) {}, /**<p>Compare this Rational to another object and see if they are equal.</p> <p>A Rational object can only be equal to another Rational object (comparing against any other type will return {@code false}).</p> <p>A Rational object is considered equal to another Rational object if and only if one of the following holds:</p> <ul><li>Both are {@code NaN}</li> <li>Both are infinities of the same sign</li> <li>Both have the same numerator and denominator in their reduced form</li> </ul> <p>A reduced form of a Rational is calculated by dividing both the numerator and the denominator by their greatest common divisor.</p> <pre>{@code (new Rational(1, 2)).equals(new Rational(1, 2)) == true // trivially true (new Rational(2, 3)).equals(new Rational(1, 2)) == false // trivially false (new Rational(1, 2)).equals(new Rational(2, 4)) == true // true after reduction (new Rational(0, 0)).equals(new Rational(0, 0)) == true // NaN.equals(NaN) (new Rational(1, 0)).equals(new Rational(5, 0)) == true // both are +infinity (new Rational(1, 0)).equals(new Rational(-1, 0)) == false // +infinity != -infinity }</pre> @param {Object {Object}} obj a reference to another object @return {Boolean} A boolean that determines whether or not the two Rational objects are equal. */ equals : function( ) {}, /**Return a string representation of this rational, e.g. {@code "1/2"}. <p>The following rules of conversion apply: <ul> <li>{@code NaN} values will return {@code "NaN"} <li>Positive infinity values will return {@code "Infinity"} <li>Negative infinity values will return {@code "-Infinity"} <li>All other values will return {@code "numerator/denominator"} where {@code numerator} and {@code denominator} are substituted with the appropriate numerator and denominator values. </ul></p> */ toString : function( ) {}, /**<p>Convert to a floating point representation.</p> @return {Number} The floating point representation of this rational number. @hide */ toFloat : function( ) {}, /**{@inheritDoc} */ hashCode : function( ) {}, /**Calculates the greatest common divisor using Euclid's algorithm. <p><em>Visible for testing only.</em></p> @param {Number} numerator the numerator in a fraction @param {Number} denominator the denominator in a fraction @return {Number} An int value representing the gcd. Always positive. @hide */ gcd : function( ) {}, /**Returns the value of the specified number as a {@code double}. <p>The {@code double} is calculated by converting both the numerator and denominator to a {@code double}; then returning the result of dividing the numerator by the denominator.</p> @return {Number} the divided value of the numerator and denominator as a {@code double}. */ doubleValue : function( ) {}, /**Returns the value of the specified number as a {@code float}. <p>The {@code float} is calculated by converting both the numerator and denominator to a {@code float}; then returning the result of dividing the numerator by the denominator.</p> @return {Number} the divided value of the numerator and denominator as a {@code float}. */ floatValue : function( ) {}, /**Returns the value of the specified number as a {@code int}. <p>{@link #isInfinite Finite} rationals are converted to an {@code int} value by dividing the numerator by the denominator; conversion for non-finite values happens identically to casting a floating point value to an {@code int}, in particular: <p> <ul> <li>Positive infinity saturates to the largest maximum integer {@link Integer#MAX_VALUE}</li> <li>Negative infinity saturates to the smallest maximum integer {@link Integer#MIN_VALUE}</li> <li><em>Not-A-Number (NaN)</em> returns {@code 0}.</li> </ul> </p> @return {Number} the divided value of the numerator and denominator as a {@code int}. */ intValue : function( ) {}, /**Returns the value of the specified number as a {@code long}. <p>{@link #isInfinite Finite} rationals are converted to an {@code long} value by dividing the numerator by the denominator; conversion for non-finite values happens identically to casting a floating point value to a {@code long}, in particular: <p> <ul> <li>Positive infinity saturates to the largest maximum long {@link Long#MAX_VALUE}</li> <li>Negative infinity saturates to the smallest maximum long {@link Long#MIN_VALUE}</li> <li><em>Not-A-Number (NaN)</em> returns {@code 0}.</li> </ul> </p> @return {Number} the divided value of the numerator and denominator as a {@code long}. */ longValue : function( ) {}, /**Returns the value of the specified number as a {@code short}. <p>{@link #isInfinite Finite} rationals are converted to a {@code short} value identically to {@link #intValue}; the {@code int} result is then truncated to a {@code short} before returning the value.</p> @return {Number} the divided value of the numerator and denominator as a {@code short}. */ shortValue : function( ) {}, /**Compare this rational to the specified rational to determine their natural order. <p>{@link #NaN} is considered to be equal to itself and greater than all other {@code Rational} values. Otherwise, if the objects are not {@link #equals equal}, then the following rules apply:</p> <ul> <li>Positive infinity is greater than any other finite number (or negative infinity) <li>Negative infinity is less than any other finite number (or positive infinity) <li>The finite number represented by this rational is checked numerically against the other finite number by converting both rationals to a common denominator multiple and comparing their numerators. </ul> @param {Object {Rational}} another the rational to be compared @return {Number} a negative integer, zero, or a positive integer as this object is less than, equal to, or greater than the specified rational. @throws NullPointerException if {@code another} was {@code null} */ compareTo : function( ) {}, /**Parses the specified string as a rational value. <p>The ASCII characters {@code \}{@code u003a} (':') and {@code \}{@code u002f} ('/') are recognized as separators between the numerator and denumerator.</p> <p> For any {@code Rational r}: {@code Rational.parseRational(r.toString()).equals(r)}. However, the method also handles rational numbers expressed in the following forms:</p> <p> "<i>num</i>{@code /}<i>den</i>" or "<i>num</i>{@code :}<i>den</i>" {@code => new Rational(num, den);}, where <i>num</i> and <i>den</i> are string integers potentially containing a sign, such as "-10", "+7" or "5".</p> <pre>{@code Rational.parseRational("3:+6").equals(new Rational(1, 2)) == true Rational.parseRational("-3/-6").equals(new Rational(1, 2)) == true Rational.parseRational("4.56") => throws NumberFormatException }</pre> @param {String} string the string representation of a rational value. @return {Object {android.util.Rational}} the rational value represented by {@code string}. @throws NumberFormatException if {@code string} cannot be parsed as a rational value. @throws NullPointerException if {@code string} was {@code null} */ parseRational : function( ) {}, };