From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 15429 invoked from network); 11 May 2004 11:44:32 -0000 Received: from thor.dotsrc.org (HELO a.mx.sunsite.dk) (130.225.247.86) by ns1.primenet.com.au with SMTP; 11 May 2004 11:44:32 -0000 Received: (qmail 22337 invoked from network); 11 May 2004 11:44:13 -0000 Received: from sunsite.dk (130.225.247.90) by a.mx.sunsite.dk with SMTP; 11 May 2004 11:44:13 -0000 Received: (qmail 15879 invoked by alias); 11 May 2004 11:44:07 -0000 Mailing-List: contact zsh-workers-help@sunsite.dk; run by ezmlm Precedence: bulk X-No-Archive: yes X-Seq: 19911 Received: (qmail 15870 invoked from network); 11 May 2004 11:44:06 -0000 Received: from thor.dotsrc.org (HELO a.mx.sunsite.dk) (qmailr@130.225.247.86) by sunsite.dk with SMTP; 11 May 2004 11:44:03 -0000 Received: (qmail 21859 invoked from network); 11 May 2004 11:44:03 -0000 Received: from finlandia.infodrom.north.de (postfix@217.89.86.34) by a.mx.sunsite.dk with SMTP; 11 May 2004 11:44:01 -0000 Received: by finlandia.infodrom.north.de (Postfix, from userid 2006) id BC06910074; Tue, 11 May 2004 13:43:56 +0200 (CEST) Date: Tue, 11 May 2004 13:43:56 +0200 From: Matthias Kopfermann To: zsh-workers@sunsite.dk Subject: print and floating point output Message-ID: <20040511114356.GA16256@finlandia.infodrom.north.de> Mime-Version: 1.0 Content-Type: text/plain; charset=iso-8859-1 Content-Disposition: inline X-Operating-System: Debian GNU/Linux User-Agent: Mutt/1.5.6i X-Spam-Checker-Version: SpamAssassin 2.63 on a.mx.sunsite.dk X-Spam-Level: X-Spam-Status: No, hits=-0.0 required=6.0 tests=BAYES_44 autolearn=no version=2.63 X-Spam-Hits: -0.0 Hi zshworkers again, something that really confused me even if i understand that floating point is a problem for a computer when converting it to binary is the result of e.g. print $((2.8*16.0)) which _sadly_, i think, returns: 44.799999999999997 I wonder if it really was a good decision to print so many numbers after the point. When asking Sven W9y he told me that that's a problem of gcc's printf/fprintf which indeed gives that result when using it with more than 15 numbers after the point. on the other hand perl, ruby and python all return the right result: perl -le 'print 2.8*16.0' => 44.8 python -c 'print 2.8*16.0' => 44.8 ruby -e 'puts 2.8*16.0' => 44.8 so i guess it would make a lot sense and not cause confusion if zsh would have a more sensible output with `print' and for users not using `printf'. Matthias