

Request #3053 Math_Fraction::makeFraction() and toString() methods ?
Submitted: 2004-12-29 12:29 UTC
From: louism Assigned: kouber
Status: Closed Package: Math_Fraction
PHP Version: Irrelevant OS: Irrelevant
Roadmaps: (Not assigned)    

 [2004-12-29 12:29 UTC] louism
Description: ------------ Hello, First of all great package, looking forward to use it. A method to make a Math_Fraction object from an x/y string representation would be nice. I've made an implementation, feel free to use/change/dtich it ;) Reproduce code: --------------- /** * Returns a PEAR:Math_Fraction object from a x/y string form * * @static * @param string string representation of fraction to make i.e., 2/3 * @return Math_Fraction object on success, PEAR error object on error * @access public */ function makeFraction($frac) { @list($num, $den) = explode('/', $frac); if (!$den) { $den = '1'; } return new Math_Fraction($num, $den); }


 [2004-12-30 03:37 UTC] kouber
Hi Louis, I will add that functionality in the next release - I want to include there also some basic documentation and unit tests. Maybe it will be added as a method in the static Math_FractionOp class, but I will also try to cover it in the Math_Fraction constructor - as is the current situation with the floatToFraction() method. Thank you!
 [2005-08-30 13:59 UTC] kouber