From owner-freebsd-current@FreeBSD.ORG Sat Apr 19 14:00:29 2003 Return-Path: Delivered-To: freebsd-current@freebsd.org Received: from mx1.FreeBSD.org (mx1.freebsd.org [216.136.204.125]) by hub.freebsd.org (Postfix) with ESMTP id BB0BF37B40C for ; Sat, 19 Apr 2003 14:00:29 -0700 (PDT) Received: from mail.rdslink.ro (mail.rdslink.ro [193.231.236.20]) by mx1.FreeBSD.org (Postfix) with SMTP id 3904F43FF5 for ; Sat, 19 Apr 2003 14:00:24 -0700 (PDT) (envelope-from enache@rdslink.ro) Received: (qmail 21400 invoked from network); 19 Apr 2003 21:02:46 -0000 Received: from unknown (HELO ratsnest.hole) (81.196.245.8) by mail.rdslink.ro with SMTP; 19 Apr 2003 21:02:46 -0000 Date: Sun, 20 Apr 2003 00:00:17 +0300 From: Enache Adrian To: current@freebsd.org Message-ID: <20030419210017.GA1263@ratsnest.hole> Mime-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline User-Agent: Mutt/1.4i cc: das@freebsd.org Subject: recent bug in printf ? X-BeenThere: freebsd-current@freebsd.org X-Mailman-Version: 2.1.1 Precedence: list List-Id: Discussions about the use of FreeBSD-current List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Sat, 19 Apr 2003 21:00:30 -0000 $ gcc -x c - && ./a.out #include int main() { printf("%.*g\n",8,0.00009); } ^D 9.0000000e-05 It appears that all others printf implementations will print '9e-05' there. It's at least what perl expects ( for its Gconvert() macro - and badly fails a lot of tests because of this ). The sprintf(3) man page claims: gG The double argument is converted in style f or e (or F or E for G conversions). The precision specifies the number of significant digits. If the precision is missing, 6 digits are given; if the precision is zero, it is treated as 1. Style e is used if the exponent from its conversion is less than -4 or greater than or equal to the precision. Trailing zeros are removed from the fractional part of the result; a decimal point appears only if it is followed by at least one digit. Should I understand that the zeros in 9.0000000e-05 aren't trailing - because the exponent follows them ? I use -CURRENT cvsup'ed 4-5 days ago. Regards Adi