From: Vincent Lefevre <vincent@vinc17.org>
To: Patrick Aussems <zyk@bugfactory.org>
Cc: zsh-users@sunsite.auc.dk
Subject: Re: Floating point calculus error...
Date: Sun, 25 Aug 2002 17:53:50 +0200 [thread overview]
Message-ID: <20020825155349.GD6783@greux.loria.fr> (raw)
In-Reply-To: <1030288941.517.8.camel@Amok>
On Sun, Aug 25, 2002 at 17:22:20 +0200, Patrick Aussems wrote:
> I was doing some shell scripts that were supposed to add CPU usages from
> the ps output... But I got puzzled when I got an answer with a 17th
> decimal while adding numbers with only 1 decimal... Strange isn't it?
The numbers are internally represented in binary and 0.4 isn't exactly
representable in binary... But here, this is a problem with zsh, which
gives an additional decimal digit. You can see with:
$ echo $[0.4]
0.40000000000000002
I think that it should give the minimum number of decimals in such a way
that when converting back to binary, one should get the same result.
--
Vincent Lefèvre <vincent@vinc17.org> - Web: <http://www.vinc17.org/> - 100%
validated (X)HTML - Acorn Risc PC, Yellow Pig 17, Championnat International
des Jeux Mathématiques et Logiques, TETRHEX, etc.
Work: CR INRIA - computer arithmetic / SPACES project at LORIA
next prev parent reply other threads:[~2002-08-25 15:54 UTC|newest]
Thread overview: 6+ messages / expand[flat|nested] mbox.gz Atom feed top
2002-08-25 15:22 Patrick Aussems
2002-08-25 15:53 ` Vincent Lefevre [this message]
2002-08-25 16:32 ` David Kågedal
2002-08-25 18:07 ` Vincent Lefevre
2002-08-25 16:01 ` Erik Trulsson
2002-08-25 16:37 ` Bart Schaefer
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20020825155349.GD6783@greux.loria.fr \
--to=vincent@vinc17.org \
--cc=zsh-users@sunsite.auc.dk \
--cc=zyk@bugfactory.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
Code repositories for project(s) associated with this public inbox
https://git.vuxu.org/mirror/zsh/
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).