Re: Math::Fraction uses faulty logic

From: Date: Tue, 13 Nov 2001 23:43:05 +0000
Subject: Re: Math::Fraction uses faulty logic
References: 1  Groups: php.pear.dev 
Request: Send a blank email to pear-dev+get-2877@lists.php.net to get a copy of this message
Wow, AML (Ascii Math Language) ? SCNR :) - Markus On Tue, Nov 13, 2001 at 06:27:53PM -0500, Colin Viebrock wrote : > 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 > > > -- > PEAR Development Mailing List (http://pear.php.net/) > To unsubscribe, e-mail: pear-dev-unsubscribe@lists.php.net > For additional commands, e-mail: pear-dev-help@lists.php.net > To contact the list administrators, e-mail: php-list-admin@lists.php.net -- Markus Fischer, http://guru.josefine.at/~mfischer/ EMail: mfischer@guru.josefine.at PGP Public Key: http://guru.josefine.at/~mfischer/C2272BD0.asc PGP Fingerprint: D3B0 DD4F E12B F911 3CE1 C2B5 D674 B445 C227 2BD0 -All your scripts are belong to Zend-

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