Newsgroups: php.internals Path: news.php.net Xref: news.php.net php.internals:33829 Return-Path: Mailing-List: contact internals-help@lists.php.net; run by ezmlm Delivered-To: mailing list internals@lists.php.net Received: (qmail 6100 invoked by uid 1010); 7 Dec 2007 15:06:02 -0000 Delivered-To: ezmlm-scan-internals@lists.php.net Delivered-To: ezmlm-internals@lists.php.net Received: (qmail 6085 invoked from network); 7 Dec 2007 15:06:02 -0000 Received: from unknown (HELO lists.php.net) (127.0.0.1) by localhost with SMTP; 7 Dec 2007 15:06:02 -0000 Authentication-Results: pb1.pair.com header.from=indeyets@gmail.com; sender-id=pass; domainkeys=bad Authentication-Results: pb1.pair.com smtp.mail=indeyets@gmail.com; spf=pass; sender-id=pass Received-SPF: pass (pb1.pair.com: domain gmail.com designates 209.85.132.244 as permitted sender) DomainKey-Status: bad X-DomainKeys: Ecelerity dk_validate implementing draft-delany-domainkeys-base-01 X-PHP-List-Original-Sender: indeyets@gmail.com X-Host-Fingerprint: 209.85.132.244 an-out-0708.google.com Received: from [209.85.132.244] ([209.85.132.244:45235] helo=an-out-0708.google.com) by pb1.pair.com (ecelerity 2.1.1.9-wez r(12769M)) with ESMTP id 29/37-00959-85169574 for ; Fri, 07 Dec 2007 10:06:00 -0500 Received: by an-out-0708.google.com with SMTP id c18so154598anc for ; Fri, 07 Dec 2007 07:05:58 -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=ZZvsJHAYHJxVmoQvoVd8ACx3r9zYudxm5T6q/neOeSw=; b=LH35N3c4aZqJGeNUeyN6fESNoZ/Bs7NWkYcO+H6YgKfOpXTpTaKgej36SRfIgL4B3hXyB/r+wlpiUKwcGdlQLjPhCgJAheZ5XDeIFMSy4COY7mUBCMY/ILBzo1PMsjfJIhBIyIk0exDr4Lzuhh4mUDUCBw2fR20/G//Shim5MEA= 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=XHFKcgCZ5RVtuJ2pmbgLFEuTyvOXzPQGgFdeb/giAFXmShTPKCTtZ7rLBIU/IRvoJrWZBOIndaTW7Tl6mfSzSDHDBOFjkQIWhdSXPgJS0DiKNKZAFcopQBZ0T2O87ymAzyWphJHu1VuSErma7f88QYvWYfZ99Y5J8s6tIS+eso8= Received: by 10.151.7.4 with SMTP id k4mr1596464ybi.1197039957948; Fri, 07 Dec 2007 07:05:57 -0800 (PST) Received: by 10.150.57.12 with HTTP; Fri, 7 Dec 2007 07:05:57 -0800 (PST) Message-ID: Date: Fri, 7 Dec 2007 18:05:57 +0300 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=UTF-8 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: indeyets@gmail.com ("Alexey Zakhlestin") I doubt this is needed in core, but sounds "ok" for an extension. Also, I believe, quite a decent version of this can be written in php (think PEAR) On 12/7/07, Nathan Rixham wrote: > 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 > > -- > PHP Internals - PHP Runtime Development Mailing List > To unsubscribe, visit: http://www.php.net/unsub.php > > -- Alexey Zakhlestin http://blog.milkfarmsoft.com/