zsh-workers
 help / color / mirror / code / Atom feed
From: "Bart Schaefer" <schaefer@candle.brasslantern.com>
To: zsh-workers@sunsite.auc.dk (Zsh hackers list)
Subject: Re: PATCH: 3.1.6-pws-4: floating point support
Date: Sat, 18 Sep 1999 18:21:42 +0000	[thread overview]
Message-ID: <990918182142.ZM6200@candle.brasslantern.com> (raw)
In-Reply-To: <9909171223.AA32858@ibmth.df.unipi.it>

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


  reply	other threads:[~1999-09-18 18:21 UTC|newest]

Thread overview: 6+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
1999-09-17 12:23 Peter Stephenson
1999-09-18 18:21 ` Bart Schaefer [this message]
1999-09-20  9:14   ` Peter Stephenson
1999-09-20 16:14     ` Peter Stephenson
1999-09-17 13:18 Sven Wischnowsky
1999-09-17 12:51 ` Peter Stephenson

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=990918182142.ZM6200@candle.brasslantern.com \
    --to=schaefer@candle.brasslantern.com \
    --cc=zsh-workers@sunsite.auc.dk \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
Code repositories for project(s) associated with this public inbox

	https://git.vuxu.org/mirror/zsh/

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).