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

Re: How to set signifcant figures of $((..)) ?



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