Maturity Index: Relatively immature
+totalFraction:aNumeratorReturns a new fraction with numerator set to aNumerator and denominator set to the element one for aNumerator.
+numerator:aNumeratordenominator:aDenominatorReturns a new fraction with numerator set to aNumerator and denominator set to aDenominator.
-copyReturns a new copy of the fraction.
-deepCopyReturns a new copy of the fraction; sends deepCopy messages to denominator and numerator.
-numeratorReturns a for a fraction a/b.
-denominatorReturns b for a fraction a/b.
- (unsigned)hashReturns a small integer that is the same for fractions that are equal in the sense of isEqual:.
- (BOOL)isEqual:bTwo fractions are equal if they are pointer equal, or if their numerators and denominators are equal. If the numerators and denominators are coprime, but not ordered, the method returns YES if numerators and denominators are opposite to each other. If the fraction is not in canonical form, it is verified that the difference of the two fractions is zero.
- (int)compare:bCompares the fractions by comparing the products of numerators and denominators.
-asNumericalReturns the numerical value of the fraction. Attempts to divide the numerical value of the numerator and denominator.
-asModp:(unsigned short)pReturns the value of the fraction modulo p. Attempts to divide the values of the numerator and denominator. If the division fails, the method generates an error message.
-asIntegralReturns, if the denominator of the fraction is equal to one, a new reference to the numerator. Otherwise, the method generates an error message.
-zeroReturns a new fraction with numerator equal to zero.
- (BOOL)isZeroWhether the numerator of the fraction is equal to zero.
- (BOOL)isOpposite:bTwo fractions are opposite if their numerators are opposite and the denominators are equal. However, if the numerators and denominators are coprime, but not ordered, the method returns YES if the numerators are equal and the denominators are opposite to each other. If the fraction is not in canonical form, it is verified that the sum of the two fractions is zero.
-negateReturns a new fraction, the opposite of self by negating the numerator.
-doubleReturns a new fraction, the double of self by doubling the numerator.
-add:bReturns a new fraction, the sum of self and b. The method first handles some special cases and then distinguishes between the case that both fractions have a common denominator or not.
-subtract:bReturns a new fraction, the difference of self and b. The method first handles some special cases and then distinguishes between the case that both fractions have a common denominator or not.
-oneReturns a new fraction with numerator equal to one.
- (BOOL)isOneWhether the numerator is equal to the denominator.
- (BOOL)isMinusOneWhether the numerator is the opposite of the denominator.
-squareReturns a new fraction; squares numerator and denominator.
-inverseReturns the inverse of the fraction; interchanges, in the case of a total fraction, denominator and numerator.
-multiply:bReturns a new fraction; multiplies the numerators and the denominators together.
-divide:bReturns a new fraction by multiplying the fraction by the inverse of b.
-power:(int)nReturns a new fraction; raises numerator and denominator to the n-th power.
-intValue:(int)intValueCreates a fraction with numerator equal to intValue and denominator one.
- (int)intValueReturns intValue of numerator divided by intValue of denominator.
-multiplyIntValue:(int)intValueReturns a new fraction by multiplying the numerator by intValue.
-divideIntValue:(int)intValueReturns a new fraction by multiplying the denominator by intValue.
- (BOOL)printsLeadingSignWhether the fraction prints a leading minus sign.
- (BOOL)printsSumWhether the fraction prints as a sum.
- (BOOL)printsProductWhether the fraction prints as a product.
-printOn:(IOD)aFilePrints the fraction to aFile by sending printOn: messages to numerator and denominator.