Newsgroups: php.internals Path: news.php.net Xref: news.php.net php.internals:33828 Return-Path: Mailing-List: contact internals-help@lists.php.net; run by ezmlm Delivered-To: mailing list internals@lists.php.net Received: (qmail 3629 invoked by uid 1010); 7 Dec 2007 14:52:47 -0000 Delivered-To: ezmlm-scan-internals@lists.php.net Delivered-To: ezmlm-internals@lists.php.net Received: (qmail 3613 invoked from network); 7 Dec 2007 14:52:47 -0000 Received: from unknown (HELO lists.php.net) (127.0.0.1) by localhost with SMTP; 7 Dec 2007 14:52:47 -0000 X-Host-Fingerprint: 82.41.129.160 82-41-129-160.cable.ubr02.glen.blueyonder.co.uk Received: from [82.41.129.160] ([82.41.129.160:26197] helo=localhost.localdomain) by pb1.pair.com (ecelerity 2.1.1.9-wez r(12769M)) with ESMTP id 01/E6-00959-D3E59574 for ; Fri, 07 Dec 2007 09:52:47 -0500 Message-ID: <01.E6.00959.D3E59574@pb1.pair.com> To: internals@lists.php.net Date: Fri, 07 Dec 2007 14:51:01 +0000 Reply-To: nrixham@gmail.com User-Agent: Thunderbird 2.0.0.9 (Windows/20071031) MIME-Version: 1.0 Content-Type: text/plain; charset=ISO-8859-1; format=flowed Content-Transfer-Encoding: 7bit X-Posted-By: 82.41.129.160 Subject: Thoughts on Feature Request - Arithmetic From: nrixham@gmail.com (Nathan Rixham) In-Built PHP Functions for parsing of basic arithmetic and if possible fraction to decimal and decimal to fraction $arithmetic_string = "3*5"; echo arith($arithmetic_string); // returns float 15 $arithmetic_string = "1/2"; echo arith($arithmetic_string); // returns float 0.5 $fraction_string = "1/4"; echo fracdec($fraction_string); // returns float 0.25 $dec_string = "0.5"; echo decfrac($dec_string); // returns string "1/4" I've used php for years, came accross the need for this today and was suprised such a basic command wasn't there.. currently the only way I can see to do it would be to eval.. which isn't the most secure method for such a basic need. Regards Nathan