Zsh Mailing List Archive
Messages sorted by:
Reverse Date,
Date,
Thread,
Author
Re: wrong value for pi?
- X-seq: zsh-workers 25353
- From: Peter Stephenson <pws@xxxxxxx>
- To: zsh-workers@xxxxxxxxxx
- Subject: Re: wrong value for pi?
- Date: Wed, 30 Jul 2008 14:13:21 +0100
- In-reply-to: <20080730125458.GB1113@xxxxxxxxx>
- Mailing-list: contact zsh-workers-help@xxxxxxxxxx; run by ezmlm
- References: <20080730125458.GB1113@xxxxxxxxx>
Julius Plenz wrote:
> Hi!
>
> Playing around, I noticed that Z-Shell wrongly evaluates the
> expression "4.0*atan(1)" (which is equal to pi):
>
> zsh> zmodload zsh/mathfunc
> zsh> typeset -F 48 pi='4.0*atan(1)'
> zsh> echo $pi
> 3.141592653589793115997963468544185161590576171875
> ^- here the first error occurs
>
> Is this indended, a bug or just owing to some sort of optimization or some C
> library's shortcomings?
It's simply a question of what double precision actually gives on your
system, as it says in the manual (" Floating point arithmetic always
uses the â??doubleâ?? type with whatever corresponding precision is
provided by the compiler and the library."). Beyond that the digits
will certainly be gobbledygook.
--
Peter Stephenson <pws@xxxxxxx> Software Engineer
CSR PLC, Churchill House, Cambridge Business Park, Cowley Road
Cambridge, CB4 0WZ, UK Tel: +44 (0)1223 692070
Messages sorted by:
Reverse Date,
Date,
Thread,
Author