Zsh Mailing List Archive
Messages sorted by:
Reverse Date,
Date,
Thread,
Author
Re: How to set signifcant figures of $((..)) ?
- X-seq: zsh-users 19051
- From: Kurtis Rader <krader@xxxxxxxxxxxxx>
- To: Zsh Users <zsh-users@xxxxxxx>
- Subject: Re: How to set signifcant figures of $((..)) ?
- Date: Tue, 2 Sep 2014 07:09:52 -0700
- In-reply-to: <20140902132234.GA2759@localhost.localdomain>
- List-help: <mailto:zsh-users-help@zsh.org>
- List-id: Zsh Users List <zsh-users.zsh.org>
- List-post: <mailto:zsh-users@zsh.org>
- Mailing-list: contact zsh-users-help@xxxxxxx; run by ezmlm
- References: <20140902132234.GA2759@localhost.localdomain>
It can't produce that output. The IEEE 754 standard for double precision
floating point values doesn't contain enough bits for more than 17 digits
of precision. See
http://en.wikipedia.org/wiki/Double-precision_floating-point_format
The reason 2**63 outputs a negative number is that integer arithmetic is
causing overflow into the sign bit of the 64 bit integer.
Also, you're using the wrong tool if you're trying to use zsh for high
precision math.
On Tue, Sep 2, 2014 at 6:22 AM, Han Pingtian <hanpt@xxxxxxxxxxxxxxxxxx>
wrote:
> Hi,
>
> I have this results:
>
> % zsh -f
> localhost% print $((2**63))
> -9223372036854775808
> localhost% print $((2.0**63))
> 9.2233720368547758e+18
> localhost%
>
> How can the second print puts 9.223372036854775808e+18, please?
>
> Thanks in advance!
>
>
--
Kurtis Rader
Caretaker of the exceptional canines Junior and Hank
Messages sorted by:
Reverse Date,
Date,
Thread,
Author