Class Fraction Number top bottom Methods Fraction abs ^ top abs / bottom ] Methods Fraction reciprocal ^ bottom / top ] Methods Fraction printString ^ top printString, '/', bottom printString ] Methods Fraction truncated " convert to an integer rounded towards zero " ^ top quo: bottom ] Methods Fraction + f f isFraction ifTrue: [ ^ ((top * f bottom) + (bottom * f top)) / (bottom * f bottom) ] ifFalse:[ ^ super + f ] ] Methods Fraction = f f isFraction ifTrue: [ ^ (top = f top) and: [ bottom = f bottom ] ] ifFalse: [ ^ super = f ] ] Methods Fraction - f f isFraction ifTrue: [ ^ ((top * f bottom) - (bottom * f top)) / (bottom * f bottom) ] ifFalse:[ ^ super - f ] ] Methods Fraction isFraction ^ true ] Methods Fraction generality " generality value - used in mixed type arithmetic " ^ 5 ] Methods Fraction * f f isFraction ifTrue: [ ^ (top * f top) / (bottom * f bottom) ] ifFalse: [ ^ super * f ] ] Methods Fraction < f f isFraction ifTrue: [ ^ (top * f bottom) < (bottom * f top) ] ifFalse:[ ^ super < f ] ] Methods Fraction top ^ top ] Methods Fraction with: t over: b " initialization " top <- t. bottom <- b ] Methods Fraction bottom ^ bottom ] Methods Fraction ln ^ (top ln) - (bottom ln) ] Methods Fraction / f ^ self * f reciprocal ] Methods Fraction asFloat " convert to a floating point number " ^ top asFloat / bottom asFloat ] Methods Fraction coerce: x " coerce a value into being a fraction " ^ x asFraction ] Methods Fraction raisedTo: x ^ (top raisedTo: x) / (bottom raisedTo: x) ]