Package home | Report new bug | New search | Development Roadmap Status: Open | Feedback | All | Closed Since Version 0.4.1

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


 [2004-12-29 17: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); }

Comments

 [2004-12-30 08: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 18:59 UTC] kouber
Thank you for your bug report. This issue has been fixed in the latest released version of the package, which you can download at http://pear.php.net/get/Math_Fraction