I represent some rational number as a fraction. All public arithmetic operations answer reduced fractions.
*
Answer the result of multiplying the receiver by aNumber.
+
Answer the sum of the receiver and aNumber.
-
Answer the difference between the receiver and aNumber.
/
Answer the result of dividing the receiver by aNumber.
negated
Refer to the comment in Number|negated.
reciprocal
Refer to the comment in Number|reciprocal.
<
Answer whether the receiver is less than the argument.
=
Compare the receiver with the argument and answer with true if the receiver is equal to the argument. Otherwise answer false.
hash
Hash is reimplemented because = is implemented.
adaptToInteger:andSend:
If I am involved in arithmetic with an Integer, convert it to a Fraction.
asFloat
Answer a Float that closely approximates the value of the receiver. Ideally, answer the Float that most closely approximates the receiver.
asFraction
Answer the receiver itself.
isFraction
Answer true if the receiver is a Fraction.
raisedToInteger:
See Number | raisedToInteger:
squared
See Fraction (Number) | squared
printOn:
Default print radix is 10
denominator
numerator
reduced
setNumerator:denominator:
truncated
Refer to the comment in Number|truncated.
numerator:denominator:
Answer an instance of me (numInteger/denInteger). NOTE: This primitive initialization method will not reduce improper fractions, so normal usage should be coded as, eg, (Fraction numerator: a denominator: b) reduced or, more simply, as a / b.