From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 12166 invoked from network); 25 Aug 2002 19:02:21 -0000 Received: from sunsite.dk (130.225.247.90) by ns1.primenet.com.au with SMTP; 25 Aug 2002 19:02:21 -0000 Received: (qmail 1332 invoked by alias); 25 Aug 2002 19:02:15 -0000 Mailing-List: contact zsh-workers-help@sunsite.dk; run by ezmlm Precedence: bulk X-No-Archive: yes X-Seq: 17579 Received: (qmail 1317 invoked from network); 25 Aug 2002 19:02:13 -0000 Date: Sun, 25 Aug 2002 15:02:08 -0400 From: dmeyer@dmeyer.net To: zsh-workers@sunsite.auc.dk Subject: Re: Floating point calculus error... Message-ID: <20020825190208.GA30222@jhereg.dmeyer.net> Reply-To: dmeyer@dmeyer.net References: <1030288941.517.8.camel@Amok> <20020825155349.GD6783@greux.loria.fr> <87k7me2921.fsf@bix.grotte> Mime-Version: 1.0 Content-Type: text/plain; charset=iso-8859-1 Content-Disposition: inline Content-Transfer-Encoding: 8bit In-Reply-To: <20020825180708.GE6783@greux.loria.fr> User-Agent: Mutt/1.4i X-Newsgroups: local.zsh-workers Organization: dmeyer.net In article <20020825180708.GE6783@greux.loria.fr> you write: > On Sun, Aug 25, 2002 at 18:32:38 +0200, David Kågedal wrote: > > Vincent Lefevre writes: > > > $ 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. > > > > But it does. > > No, this is not the *minimum* number of decimal digits. 0.4 would > be sufficient in this case. This is a bad idea, IMHO. The number is internally represented as 0.40000000000000002, and that's what should be printed out. If you don't like all the digits, use printf. -- Dave Meyer dmeyer@dmeyer.net