*X-seq*: zsh-workers 42348*From*: Stephane Chazelas <stephane.chazelas@xxxxxxxxx>*To*: Daniel Shahaf <d.s@xxxxxxxxxxxxxxxxxx>*Subject*: Re: inf and nan in arithmetic expansions*Date*: Thu, 8 Feb 2018 14:22:11 +0000*Cc*: zsh-workers@xxxxxxx*Dkim-signature*: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=date:from:to:cc:subject:message-id:mail-followup-to:references :mime-version:content-disposition:in-reply-to:user-agent; bh=r5avhjJAqLSZwthOblVhuqkD863RTAOsVSIVMObPdYs=; b=lPtAKD9JBdEauLELjXOLEvWoRN7u3X+yp2YPgJDmxm4tPxuLP89Zl3Bu2bL9DQ2len QeMh+a9Hha6omvRsfQdC0wP4A2/FeBO/qc3zoK9cSyPA/lVZGajAFlUstCHCsGXhuPzz qn3tp97mFbjnnxOKXEvhGftSsgHtyPNuDCjqWFfAE88CBy1B04a2ol2i+CbI8vf6tvy7 hUlDyIyl/guo3LkZ+6egNEcfqKeoPL0cyevFhWSMjGdIFiAG23ChMjVgelUnS3U4he8f mpy1orT++RqY2AikpBjm5j7BncPdGP+FU2+0a1qC8mFEUPz2Th7Omm9XchV/meb7Bhmd borA==*In-reply-to*: <1518093995.645366.1263935336.265ED7BF@webmail.messagingengine.com>*List-help*: <mailto:zsh-workers-help@zsh.org>*List-id*: Zsh Workers List <zsh-workers.zsh.org>*List-post*: <mailto:zsh-workers@zsh.org>*List-unsubscribe*: <mailto:zsh-workers-unsubscribe@zsh.org>*Mail-followup-to*: Daniel Shahaf <d.s@xxxxxxxxxxxxxxxxxx>, zsh-workers@xxxxxxx*Mailing-list*: contact zsh-workers-help@xxxxxxx; run by ezmlm*References*: <20180207223051.GA30393@chaz.gmail.com> <4253.1518045946@thecus.kiddle.eu> <1518093995.645366.1263935336.265ED7BF@webmail.messagingengine.com>

2018-02-08 12:46:35 +0000, Daniel Shahaf: [...] > Why do we generate "inf." with a period in the first place? I know of > no other tool that does this. Shouldn't we generate "inf" and "nan" > with no period? [...] The idea is that we add "." for floats that don't already have one and don't have a e/E to make sure they stay floats when used again in an arithmetic expression. That causes all sorts of problems with yash and ksh93 which don't do that. See https://unix.stackexchange.com/a/422123 for a few examples. It just looks like "inf" and "nan" were overlooked. Whether we output "inf", "Inf" or "inf.", we'd also want to make sure they're recognised on input. > And then we could add 'inf' and 'nan' as readonly variables initialised to > those respective values (as Oliver also suggests in the 19597 thread). There > are compatibility implications for scripts that use these variable names, but > there is no way around them if we want to allow explicitly doing (( x = inf )) > in user code... But what value would you use for those variables? Or do you mean that the shell arithmetic parser would understand "inf"/"nan" as the infinity and not-a-number numbers and not as the variable (otherwise with inf=inf, that would do infinite recursion) but just make inf/nan readonly so users not be tempted to use them as variables? I'd also rather "inf" be used instead of "inf." (would also align with ksh93), but the change could potentially break some scripts. If we also make $inf/$nan read-only variables, that would also break scripts that use $inf/$nan variables but not in arithmetic contexts (like for inf in *.inf), so that doesn't sound like a good idea to me. -- Stephane

**Follow-Ups**:**Re: inf and nan in arithmetic expansions***From:*Daniel Shahaf

**References**:**inf and nan in arithmetic expansions***From:*Stephane Chazelas

**Re: inf and nan in arithmetic expansions***From:*Oliver Kiddle

**Re: inf and nan in arithmetic expansions***From:*Daniel Shahaf

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