From mboxrd@z Thu Jan 1 00:00:00 1970 X-Msuck: nntp://news.gmane.org/gmane.linux.lib.musl.general/4823 Path: news.gmane.org!not-for-mail From: Morten Welinder Newsgroups: gmane.linux.lib.musl.general Subject: Re: printf issues Date: Mon, 7 Apr 2014 09:40:53 -0400 Message-ID: References: <20140404141515.GD3034@port70.net> <20140404150705.GN26358@brightrain.aerifal.cx> <20140404185413.GH3034@port70.net> <20140404210837.GS26358@brightrain.aerifal.cx> <20140407072930.GB26358@brightrain.aerifal.cx> Reply-To: musl@lists.openwall.com NNTP-Posting-Host: plane.gmane.org Mime-Version: 1.0 Content-Type: text/plain; charset=ISO-8859-1 X-Trace: ger.gmane.org 1396878076 19595 80.91.229.3 (7 Apr 2014 13:41:16 GMT) X-Complaints-To: usenet@ger.gmane.org NNTP-Posting-Date: Mon, 7 Apr 2014 13:41:16 +0000 (UTC) To: musl@lists.openwall.com Original-X-From: musl-return-4827-gllmg-musl=m.gmane.org@lists.openwall.com Mon Apr 07 15:41:08 2014 Return-path: Envelope-to: gllmg-musl@plane.gmane.org Original-Received: from mother.openwall.net ([195.42.179.200]) by plane.gmane.org with smtp (Exim 4.69) (envelope-from ) id 1WX9nQ-0005OD-Ii for gllmg-musl@plane.gmane.org; Mon, 07 Apr 2014 15:41:08 +0200 Original-Received: (qmail 28443 invoked by uid 550); 7 Apr 2014 13:41:06 -0000 Mailing-List: contact musl-help@lists.openwall.com; run by ezmlm Precedence: bulk List-Post: List-Help: List-Unsubscribe: List-Subscribe: Original-Received: (qmail 28426 invoked from network); 7 Apr 2014 13:41:05 -0000 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20120113; h=mime-version:in-reply-to:references:date:message-id:subject:from:to :content-type; bh=SpIeyNfdcTJkyjjn+ivFfJM9D09O5ZE/wo/h8oi5fiM=; b=C/wr6vS6zGUrSpRPJk5aeBK+UiPIDvMmsVijCLBE0WuVZ/jGOlzQdtM4K37ZVPNbaZ sJ2fOJq8HoVZipDpNzGee4TrLO/Zg+PI2zQ91Es36JKCePu/zjTtZoz7dKzJhCGNgw8L dpJlkozBogwY07dNeyQJKj7Hv6L4YZVHj/Oe5OIzobvfMkTE4uxCCMDWXAFjVSQtClxb gDIoPZrR1Z4P4gabq1gsGE2BxH/SP2I985GMUdoVHFs7ypUly35Yn0YqpCILdO0XqJr/ 55yiUOSWMVUTUO2o22K8I6/IPak4Qd1j0vjSCdqQ6lNTizl99bu2+yQuJZPOZ5+imWp7 s1+A== X-Received: by 10.194.58.180 with SMTP id s20mr42457530wjq.54.1396878053961; Mon, 07 Apr 2014 06:40:53 -0700 (PDT) In-Reply-To: <20140407072930.GB26358@brightrain.aerifal.cx> Xref: news.gmane.org gmane.linux.lib.musl.general:4823 Archived-At: I am seeing another case of printing the wrong result. (This is with the pre-fix code, but I don't think that matters.) For 0xc.301316272b908p+49L (aka 6861116509411105.0L) with format "%.15Lg" I get musl: 6.86111650941111e+15 glibc: 6.8611165094111e+15 Musl has rounded to odd here for a midpoint case. Morten On Mon, Apr 7, 2014 at 3:29 AM, Rich Felker wrote: > On Fri, Apr 04, 2014 at 08:01:00PM -0400, Morten Welinder wrote: >> I *think* the right fix is to add the following "if' statement into >> the rounding loop: >> >> while (*d > 999999999) { >> *d--=0; >> if (d < a) *--a = 0; >> (*d)++; >> } >> >> This also ought to make the d> more tests would be better. > > After re-studying the code, I think this is the correct fix, and I've > committed the fix to git. I also fixed the bug where %g failed to trim > trailing zeros. > > Rich