zsh-workers
 help / color / mirror / code / Atom feed
From: Oliver Kiddle <okiddle@yahoo.co.uk>
To: Zsh hackers list <zsh-workers@zsh.org>
Subject: Re: inf and nan in arithmetic expansions
Date: Thu, 08 Feb 2018 00:25:46 +0100	[thread overview]
Message-ID: <4253.1518045946@thecus.kiddle.eu> (raw)
In-Reply-To: <20180207223051.GA30393@chaz.gmail.com>

Stephane Chazelas wrote:
>
> neither "inf." nor "inf" are understood in arithmetic
> expressions (and for "inf.", nor by other tools like awk, or
> even the builtin printf):

> It should be safe to change zsh so that inf. (and Inf. INF. NAN.
> nan., maybe also Infinity.) are recognised in arithmetic
> expression, as it's currently invalid, but that leaves the
> problem of "inf." not being recognised by other tools
> (awk/printf).

There was actually a patch posted back in workers/19597 to do this. I
don't know why it never got integrated other than that a certain
amount of integration work was perhaps required.

It might be possible to forward port that work from 4.1.1 to the current
release. Would that be welcomed or was the original patch rejected for
good reasons? Any idea of where we might crib some decent test cases for
IEEE 754 arithmetic from?

> The printf builtin understands the C99 hex with binary
> exponent on input (where strtod supports them), but not on
> output (%a, %A) and not in arithmetic expressions
>
> $ printf "%g\n" 0x1p4
> 16
> $ printf "%a\n" 16
> printf: %a: invalid directive

This was down to %a not having been portable to all systems in wide
use at the time zsh's printf was written: we rely on the underlying C
library printf. Adding an autoconf test would have been a lot more work
than the code change to support it. From a quick check of man pages,
this is perhaps not a problem anymore. Could we add it today without
bothering with autoconf magic?

Oliver


  reply	other threads:[~2018-02-08  7:32 UTC|newest]

Thread overview: 15+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2018-02-07 22:30 Stephane Chazelas
2018-02-07 23:25 ` Oliver Kiddle [this message]
2018-02-08  9:38   ` Peter Stephenson
2018-02-08 12:46   ` Daniel Shahaf
2018-02-08 14:22     ` Stephane Chazelas
2018-02-09 15:31       ` Daniel Shahaf
2018-02-09 21:09         ` Stephane Chazelas
2018-02-10  0:10           ` Bart Schaefer
2018-02-16 16:51     ` Oliver Kiddle
2018-02-17  0:38       ` Daniel Shahaf
2018-02-19 14:19         ` Stephane Chazelas
2018-02-27 13:02       ` Vincent Lefevre
2018-02-27 15:25         ` Oliver Kiddle
2018-02-27 16:56           ` Vincent Lefevre
2018-03-21 23:46       ` Oliver Kiddle

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=4253.1518045946@thecus.kiddle.eu \
    --to=okiddle@yahoo.co.uk \
    --cc=zsh-workers@zsh.org \
    /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).