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

Re: inf and nan in arithmetic expansions



On 2018-02-16 17:51:15 +0100, Oliver Kiddle wrote:
> On 8 Feb, Daniel Shahaf wrote:
> > 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?
> 
> This is actually system specific. We generate whatever printf(3)
> generates. Try out Stephane's examples on Solaris and you get Inf and
> NaN instead. I think I prefer those forms. We can make the printf code
> detect them and hard code a consistent form so that we are consistent
> across platforms.

What do you mean by "We generate whatever printf(3) generates."?

On Debian/unstable:

cventin% echo $((1e9999))
inf.
cventin% printf "%g\n" 1e9999
inf
cventin% /usr/bin/printf "%g\n" 1e9999
/usr/bin/printf: ‘1e9999’: Numerical result out of range
inf

-- 
Vincent Lefèvre <vincent@xxxxxxxxxx> - Web: <https://www.vinc17.net/>
100% accessible validated (X)HTML - Blog: <https://www.vinc17.net/blog/>
Work: CR INRIA - computer arithmetic / AriC project (LIP, ENS-Lyon)



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