I know I have an earlier version of the book, but could not find a correction, unless I am wrong in reading the example:
In the book, these two methods:
-(Fraction *) mul: (Fraction *) f
{
Fraction *result = [[Fraction alloc] init];
//*********
[result setTo: numerator * f.numerator
over: denominator * f.denominator];
//********
[result reduce];
return result;
}
-(Fraction *) div: (Fraction *) f
{
Fraction *result = [[Fraction alloc] init];
//**********
[result setTo: numerator * f.denominator
over: denominator * f.numerator];
//*********
[result reduce];
return result;
}
Wouldn't they produce the same result since no math was really applied?
Should they have followed these formulas?
numerator = ((a*d) * (b*c)) / (b * d) //For Multiply
and
numerator = ((a*d) / (b*c)) / (b * d) //For Division
since the output in the book shows otherwise?