From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 11282 invoked from network); 18 Sep 1999 18:21:58 -0000 Received: from sunsite.auc.dk (130.225.51.30) by ns1.primenet.com.au with SMTP; 18 Sep 1999 18:21:58 -0000 Received: (qmail 14411 invoked by alias); 18 Sep 1999 18:21:49 -0000 Mailing-List: contact zsh-workers-help@sunsite.auc.dk; run by ezmlm Precedence: bulk X-No-Archive: yes X-Seq: 7928 Received: (qmail 14403 invoked from network); 18 Sep 1999 18:21:47 -0000 From: "Bart Schaefer" Message-Id: <990918182142.ZM6200@candle.brasslantern.com> Date: Sat, 18 Sep 1999 18:21:42 +0000 In-Reply-To: <9909171223.AA32858@ibmth.df.unipi.it> Comments: In reply to Peter Stephenson "PATCH: 3.1.6-pws-4: floating point support" (Sep 17, 2:23pm) References: <9909171223.AA32858@ibmth.df.unipi.it> X-Mailer: Z-Mail (5.0.0 30July97) To: zsh-workers@sunsite.auc.dk (Zsh hackers list) Subject: Re: PATCH: 3.1.6-pws-4: floating point support MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii On Sep 17, 2:23pm, Peter Stephenson wrote: } Subject: PATCH: 3.1.6-pws-4: floating point support } } Here's my first go at floating point support. } } Outside an immediate numeric context, such as a $((...)) or a normal array } subscript, there is no special way of telling whether an integer or float } is required. So if you need an integer but use a float, the decimal point } is liable to get in the way. But that's inevitable. What's the most appropriate idiom for forcing a floating point number to be interpreted as an integer, e.g. to force integer division? The thing that bothers me most -- and I don't know what if anything ksh does about this, so maybe it's moot -- is that ((x=y)) where y is float and x was not previously defined, creates x as float, which may be unexpected (if the assignment is in code that's held over from pre- float zsh). This is similar to, but more subtle than, the for-((...))-loop problem that appears as an example in the doc. Being required to predeclare variables with "integer" or "float" from outside the ((...)) context feels a bit clumsy to me, so I hope there's a better way. While doing some random fooling around with this, I noticed: zagzig<23> ((integer florp=9.2)) zsh: bad math expression: unbalanced stack zagzig<24> typeset -F florp=9.2000000000 The variable got assigned in spite of the syntax error? Ouch. Finally, there's a typo in the doc. Index: Doc/Zsh/builtins.yo =================================================================== @@ -348,7 +348,7 @@ If no var(job) is specified, resume the current job. ) findex(float) -item(tt(float) [ {tt(PLUE())|tt(-)}tt(EFghlrtux) ] [ var(name)[tt(=)var(value)] ... ])( +item(tt(float) [ {tt(PLUS())|tt(-)}tt(EFghlrtux) ] [ var(name)[tt(=)var(value)] ... ])( Equivalent to tt(typeset -E), except that options irrelevant to floating point numbers are not permitted. ) -- Bart Schaefer Brass Lantern Enterprises http://www.well.com/user/barts http://www.brasslantern.com