Newsgroups: php.internals Path: news.php.net Xref: news.php.net php.internals:33833 Return-Path: Mailing-List: contact internals-help@lists.php.net; run by ezmlm Delivered-To: mailing list internals@lists.php.net Received: (qmail 26594 invoked by uid 1010); 7 Dec 2007 16:06:59 -0000 Delivered-To: ezmlm-scan-internals@lists.php.net Delivered-To: ezmlm-internals@lists.php.net Received: (qmail 26572 invoked from network); 7 Dec 2007 16:06:58 -0000 Received: from unknown (HELO lists.php.net) (127.0.0.1) by localhost with SMTP; 7 Dec 2007 16:06:58 -0000 Authentication-Results: pb1.pair.com smtp.mail=parasane@gmail.com; spf=pass; sender-id=pass Authentication-Results: pb1.pair.com header.from=parasane@gmail.com; sender-id=pass; domainkeys=bad Received-SPF: pass (pb1.pair.com: domain gmail.com designates 209.85.198.189 as permitted sender) DomainKey-Status: bad X-DomainKeys: Ecelerity dk_validate implementing draft-delany-domainkeys-base-01 X-PHP-List-Original-Sender: parasane@gmail.com X-Host-Fingerprint: 209.85.198.189 rv-out-0910.google.com Received: from [209.85.198.189] ([209.85.198.189:36616] helo=rv-out-0910.google.com) by pb1.pair.com (ecelerity 2.1.1.9-wez r(12769M)) with ESMTP id 8B/40-16679-0D869574 for ; Fri, 07 Dec 2007 10:37:53 -0500 Received: by rv-out-0910.google.com with SMTP id k15so701500rvb for ; Fri, 07 Dec 2007 07:37:50 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=gamma; h=domainkey-signature:received:received:message-id:date:from:to:subject:cc:in-reply-to:mime-version:content-type:content-transfer-encoding:content-disposition:references; bh=OsVixsno03r+iSDcacYP7Q7KZmsFlVCRbtPP635lVRc=; b=K51QjLrTncscxKboZQDLzvZU4t3Q8z54rq6vHuDuIRSTAvez4VhtkPJvxlC8NP3FTzHBacKfJXRQRXacoAXDTKAoNve+L3TMAo7S6T0c8CpEoKFtVRCD9TORU7H4+TGNUuQ6SplJQlKGNd9zU+qXAAT3tIWYBg+s+v65ysb9w7M= DomainKey-Signature: a=rsa-sha1; c=nofws; d=gmail.com; s=gamma; h=message-id:date:from:to:subject:cc:in-reply-to:mime-version:content-type:content-transfer-encoding:content-disposition:references; b=O9o98w6LKsvcfvZ6B/76RNJSS6W32JcyMACXuzflYK0lGvPb6HoLUEqzPlwIMS6iAjaOSyjHWOQi0mnVzYwJCNXbAiwiv2N136Czk2QDBQ2IOkM1ndCDBF6Myz+Wv/713v/NCfZAkHlOahUT0OjeE810WsJ7aGeDF8YbsrxqZAA= Received: by 10.140.192.9 with SMTP id p9mr2026705rvf.1197041869978; Fri, 07 Dec 2007 07:37:49 -0800 (PST) Received: by 10.141.52.8 with HTTP; Fri, 7 Dec 2007 07:37:49 -0800 (PST) Message-ID: Date: Fri, 7 Dec 2007 10:37:49 -0500 To: nrixham@gmail.com Cc: internals@lists.php.net In-Reply-To: <01.E6.00959.D3E59574@pb1.pair.com> MIME-Version: 1.0 Content-Type: text/plain; charset=ISO-8859-1 Content-Transfer-Encoding: 7bit Content-Disposition: inline References: <01.E6.00959.D3E59574@pb1.pair.com> Subject: Re: [PHP-DEV] Thoughts on Feature Request - Arithmetic From: parasane@gmail.com ("Daniel Brown") On Dec 7, 2007 9:51 AM, Nathan Rixham wrote: > In-Built PHP Functions for parsing of basic arithmetic and if possible > fraction to decimal and decimal to fraction PHP already handles half of what you're looking for by default. > $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" Now I see why you need PHP to do your math for you! ;-P There are functions written that do this now though. > 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 > > -- > PHP Internals - PHP Runtime Development Mailing List > To unsubscribe, visit: http://www.php.net/unsub.php > > -- Daniel P. Brown [Phone Numbers Go Here!] [They're Hidden From View!] If at first you don't succeed, stick to what you know best so that you can make enough money to pay someone else to do it for you.