Zsh Mailing List Archive
Messages sorted by: Reverse Date, Date, Thread, Author

Re: News: zsh-4.1.1-nonstop-fp



On 6 Mar, "Nelson H. F. Beebe" wrote:
> 
> that contains improvements in the handling of floating-point
> arithmetic.  I invite comments from the zsh developers, and I plan in

This definitely looks good to me.

It's a pity printf outputs `nan' and `inf' in lowercase while it
otherwise uses `NaN' and `Inf'. The printf builtin could be changed but
it isn't trivial because of things like the width modifiers. printf's
output may even be platform specific.

It might be better to add readonly special variables named Inf and NaN
instead of modifying zzlex to do a strcmp. Given the following existing
behaviour, I think that'd work:
  % y=x
  % x=3.141
  % echo $(( y ))
  3.141

Note that you can do things like:
  (( x = 1.0 / 0.0 ))
instead of:
  x=$(( 1.0 / 0.0 ))

You are otherwise getting conversions via a string which is less
efficient and for some numbers will lose you a lot of precision.

Similarly, the builtin printf allows things like:
  printf '%g\n' x
instead of:
  printf '%g\n' $x
and even things like:
  printf '%g\n' '1.0 / 0.0'

I just noticed that the scripts used the other forms which may be
necessary for compatibility with other shells.

Looking through the patch Clint sent, we could probably remove the
NONSTOP_FP preprocessor define. Can't see that we'd have a need for a
--disable-nonstop-fp configure option. The ksh93-test.sh script is
testing the capabilities of various shells rather than the nonstop-fp
functionality so we probably don't need it. Examples from the README
could be adapted for something in the Test directory though.

Oliver



Messages sorted by: Reverse Date, Date, Thread, Author