Math::Fraction uses faulty logic

From: Date: Tue, 13 Nov 2001 23:27:53 +0000
Subject: Math::Fraction uses faulty logic
Groups: php.pear.dev 
Request: Send a blank email to pear-dev+get-2876@lists.php.net to get a copy of this message
I'm pretty sure the logic in Math::Fraction for adding and subtracting fractions is wrong. Given: n1 n2 ---- + ---- d1 d2 The current code basically says the answer is: ( n1 + n2 ) ------------- ( d1 * d2 ) Try that for 1/2 + 1/4 and you'll see it should be: ( n1 * d2 ) + ( n2 * d1 ) --------------------------- ( d1 * d2 ) Similarly, subtracting should be: ( n1 * d2 ) - ( n2 * d1 ) --------------------------- ( d1 * d2 ) - Colin

« previous php.pear.dev (#2876) next »