From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 24710 invoked by alias); 5 Mar 2013 20:02:32 -0000 Mailing-List: contact zsh-users-help@zsh.org; run by ezmlm Precedence: bulk X-No-Archive: yes List-Id: Zsh Users List List-Post: List-Help: X-Seq: 17666 Received: (qmail 4049 invoked from network); 5 Mar 2013 20:02:31 -0000 X-Spam-Checker-Version: SpamAssassin 3.3.2 (2011-06-06) on f.primenet.com.au X-Spam-Level: X-Spam-Status: No, score=-2.6 required=5.0 tests=BAYES_00,RCVD_IN_DNSWL_LOW autolearn=ham version=3.3.2 Received-SPF: neutral (ns1.primenet.com.au: 74.125.82.43 is neither permitted nor denied by SPF record at ntlworld.com) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20120113; h=x-received:x-proxyuser-ip:date:from:to:subject:message-id :in-reply-to:references:x-mailer:mime-version:content-type :content-transfer-encoding:x-gm-message-state; bh=j3kqaCC3s2ViDc4Kxm2d1bCylaw/fZ5buVpy00cfZLc=; b=WuW5DytOXb5XVvu7BuIwtKk9I6P+DBsj5X5qQ5FTsuBhqUX0oE3fyl8JqiJ36giqpd PWJuRhTIMPmm/sATfAYOgnZjOpJ7s+aZlKCC58Zv73GAcCed2/18F6Sgt++r/MfiJ701 YbIWEjcUmh099PwRHF5atHi6JCqRBcH9forWQDjmX9ORciHvL11o2hO1fHD9dTrpvVmY hh6DR0vWF+AzyIhL727zWnzAvVK4JDs/4KEUZw67G1L9jNAcvz3RnhN5XqnGbx59SoLn iYjk8X80KXOlvaIrVk5i7RL9/DuJnOb5vD+O0vUTWjAbJoSNcaSqF6WJ/Ul1OqT0VhS1 dQ8Q== X-Received: by 10.180.103.40 with SMTP id ft8mr21480727wib.28.1362513746056; Tue, 05 Mar 2013 12:02:26 -0800 (PST) X-ProxyUser-IP: 86.26.6.143 Date: Tue, 5 Mar 2013 20:02:19 +0000 From: Peter Stephenson To: zsh-users@zsh.org Subject: Re: force floating point arithmetics Message-ID: <20130305200219.54addb4a@pws-pc.ntlworld.com> In-Reply-To: <20130305195147.690e801b@pws-pc.ntlworld.com> References: <20130304072902.GA9639@chaz.gmail.com> <20130305195147.690e801b@pws-pc.ntlworld.com> X-Mailer: Claws Mail 3.8.0 (GTK+ 2.24.7; x86_64-redhat-linux-gnu) Mime-Version: 1.0 Content-Type: text/plain; charset=US-ASCII Content-Transfer-Encoding: 7bit X-Gm-Message-State: ALoCoQnoZE3KLJ8F8ymrGomxIvZeqS/OUIr0n9sWNJTJilyzCatiYKYtbeYxfYEZr1LPaJhzfvIS On Tue, 5 Mar 2013 19:51:47 +0000 Peter Stephenson wrote: > Works quite well with zcalc, I should probably make it an option. Index: Doc/Zsh/contrib.yo =================================================================== RCS file: /cvsroot/zsh/zsh/Doc/Zsh/contrib.yo,v retrieving revision 1.147 diff -p -u -r1.147 contrib.yo --- Doc/Zsh/contrib.yo 26 Jan 2013 22:54:01 -0000 1.147 +++ Doc/Zsh/contrib.yo 5 Mar 2013 20:00:42 -0000 @@ -3158,6 +3158,10 @@ The output base can be initialised by pa for example `tt(zcalc -#16)' (the `tt(#)' may have to be quoted, depending on the globbing options set). +If the option `tt(-f)' is set, all numbers are treated as floating +point, hence for example the expression `tt(3/4)' evaluates to 0.75 +rather than 0. Options must appear in separate words. + The prompt is configurable via the parameter tt(ZCALCPROMPT), which undergoes standard prompt expansion. The index of the current entry is stored locally in the first element of the array tt(psvar), which can be Index: Functions/Misc/zcalc =================================================================== RCS file: /cvsroot/zsh/zsh/Functions/Misc/zcalc,v retrieving revision 1.20 diff -p -u -r1.20 zcalc --- Functions/Misc/zcalc 28 Jul 2010 14:01:12 -0000 1.20 +++ Functions/Misc/zcalc 5 Mar 2013 20:00:42 -0000 @@ -114,7 +114,7 @@ float PI E (( PI = 4 * atan(1), E = exp(1) )) # Process command line -while [[ -n $1 && $1 = -(|[#-]*) ]]; do +while [[ -n $1 && $1 = -(|[#-]*|f) ]]; do optlist=${1[2,-1]} shift [[ $optlist = (|-) ]] && break @@ -139,6 +139,9 @@ while [[ -n $1 && $1 = -(|[#-]*) ]]; do fi defbase="[#${arg}]" ;; + (f) # Force floating point operation + setopt forcefloat + ;; esac done done -- Peter Stephenson Web page now at http://homepage.ntlworld.com/p.w.stephenson/